It seems like you want a function that encodes all string properties of any given object.
To do this, you can use a bit of reflection. Note however, that the function below performs the encoding in-place. If you need it to return an encoded copy of the original object, you'll need to do some cloning (which can get pretty complicated if you need deep cloning).
public static void EncodeAllProperties(object obj)
{
var props = obj.GetType().GetProperties();
foreach (var prop in props)
{
if (prop.PropertyType == typeof(string))
{
prop.SetValue(obj, Base64Encode(prop.GetValue(obj) as string));
}
}
}
// From https://stackoverflow.com/a/11743162/11981207
public static string Base64Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}