C# 无法将sql连接字符串转换为字节[]
我正在尝试转换包含普通字符和“',”;”,和“=” 当我尝试这样做时:C# 无法将sql连接字符串转换为字节[],c#,sql,encryption,cryptography,bytearray,C#,Sql,Encryption,Cryptography,Bytearray,我正在尝试转换包含普通字符和“',”;”,和“=” 当我尝试这样做时: Byte[] byt = Convert.FromBase64String(value); 我收到了这个错误消息 An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: The input is not a valid Base-64 string as it cont
Byte[] byt = Convert.FromBase64String(value);
我收到了这个错误消息
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
补充:
-我用它来加密一个sqlstring
-使用相同函数的my decrypt工作正常,但在尝试转换回加密时失败这正是您的问题
Byte[] byt = Convert.FromBase64String(value);
输入不是有效的Base-64字符串
您正在尝试从未提供的base64字符串转换
byte[] byt = Encoding.ASCII.GetBytes(value);
转换回字符串
string value = Encoding.ASCII.GetString(byt);