【发布时间】:2013-05-19 23:43:37
【问题描述】:
我正在处理解密密码,但我遇到了这个错误:
字符串长度不能为零。参数名称:oldValue
请帮助解决此错误或建议我使用另一个解密程序。
这里是完整的代码:
string decryptpwd = string.Empty;
UTF8Encoding encodepwd = new UTF8Encoding();
Decoder Decode = encodepwd.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(encryptpwd.Replace("+",""));
int charcount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decode_char = new char[charcount];
Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decode_char, 0);
decryptpwd = new String(decode_char);
return decryptpwd;
【问题讨论】:
-
Base64 不是加密。您必须散列密码。
-
错误的哪一部分你不明白?你的代码没有意义。
-
@FreeLancer 这是我的完整代码,我使用来自网站的代码 string decryptpwd = string.Empty; UTF8Encoding encodepwd = new UTF8Encoding();解码器解码 = encodepwd.GetDecoder(); byte[] todecode_byte = Convert.FromBase64String(encryptpwd.Replace("+","")); int charcount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); char[] decode_char = new char[charcount];解码.GetChars(todecode_byte, 0, todecode_byte.Length, decode_char, 0); decryptpwd = new String(decode_char);返回解密密码;
标签: c# asp.net encryption