base64 to byte array c# code example

Example 1: base64 string to byte array c#

byte[] l_Data = Convert.FromBase64String(l_PlainText);

Example 2: c# number to byte array

public byte[] ConvertNumToByte(int Number)
{
  byte[] ByteArray = new byte[32];
  string BinString = Convert.ToString(Number, 2);
  char[] BinCharArray = BinString.ToCharArray();
  try
  {
    System.Array.Reverse(BinCharArray);
    if (BinCharArray != null && BinCharArray.Length > 0)
    {
      for (int index = 0; index < BinCharArray.Length; ++index)
      {
        ByteArray[index] = Convert.ToByte(Convert.ToString(BinCharArray[index]));
      }
    }
  }
  catch
  {
  }
  return ByteArray;
}

Example 3: c# byte array to base64

public static string ToBase64String (byte[] inArray, int offset, int length, Base64FormattingOptions options);

Example 4: byte array to base64 c#

byte[] temp_backToBytes = Convert.FromBase64String(temp_inBase64);