How to convert string to base64 byte array, would this be valid?

后端 未结 5 2029
温柔的废话
温柔的废话 2021-02-03 20:20

I\'m trying to write a function that converts a string to a base64 byte array. I\'ve tried with this approach:

public byte[] stringToBase64ByteArray(String input         


        
5条回答
  •  梦谈多话
    2021-02-03 21:00

    You can use:

    From byte[] to string:

    byte[] array = somebytearray;

    string result = Convert.ToBase64String(array);

    From string to byte[]:

    array = Convert.FromBase64String(result);

提交回复
热议问题