String to binary method:
public static string StringToBinary(string data)
{
StringBuilder sb = new StringBuilder(); foreach (char c in data.ToCharArray())
{
sb.Append(Convert.ToString(c, ).PadLeft(, ''));
}
return sb.ToString();
}
Binary to string method:
public static string BinaryToString(string data)
{
List<Byte> byteList = new List<Byte>(); for (int i = ; i < data.Length; i += )
{
byteList.Add(Convert.ToByte(data.Substring(i, ), ));
}
return Encoding.ASCII.GetString(byteList.ToArray());
}