Hil*_*boy -1 c# sql encryption cryptography bytearray
我试图转换包含普通字符和'_',';'和'='的sqlstring,当我尝试这样做时:
Byte[] byt = Convert.FromBase64String(value);
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息
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.
Run Code Online (Sandbox Code Playgroud)
Additonal: - 我用它来加密sqlstring -my解密,它使用同样的功能工作正常,但在尝试转换回加密时失败
这正是你的问题
Byte[] byt = Convert.FromBase64String(value);
Run Code Online (Sandbox Code Playgroud)
输入不是有效的Base-64字符串
您正在尝试从您未提供的base64字符串进行转换
byte[] byt = Encoding.ASCII.GetBytes(value);
Run Code Online (Sandbox Code Playgroud)
转换回字符串
string value = Encoding.ASCII.GetString(byt);
Run Code Online (Sandbox Code Playgroud)