添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
坏坏的眼镜  ·  【Unity】2D ...·  1 周前    · 
温暖的鸵鸟  ·  causal inference in ...·  2 月前    · 
淡定的茶壶  ·  ubuntu 18.04 ...·  1 年前    · 
热情的硬币  ·  gdb 常用命令 - 知乎·  1 年前    · 
public string DecryptData( string encryptedtext) byte[] encryptedBytes = Convert.FromBase64String(encryptedtext); MemoryStream ms = new MemoryStream(); CryptoStream decStream = new CryptoStream(ms, tripleDESCryptoServiceProvider.CreateDecryptor(), CryptoStreamMode.Write); decStream.Write(encryptedBytes, 0 , encryptedBytes.Length); decStream.FlushFinalBlock(); return System.Text.Encoding.Unicode.GetString(ms.ToArray()); Login Code :-
MessageBox.Show(Crypto.DecryptData(obj.password))
when we call decrypt method then give an exception that is Invalid length for a Base-64 char array or string For a string to be a valid Base64 string, its length must have a multiple of 4...
Check your input string's length...
http://en.wikipedia.org/wiki/Base64 [ ^ ] // byte[] encryptedBytes = Convert.FromBase64String(encryptedtext); byte[] encryptedBytes = Encoding.ASCII.GetBytes(encryptedtext);
This will eliminate the "Invalid length" error.
Moreover: How can you decrypt without providing a key?
Please have a look here:
Encrypt and Decrypt Data with C# [ ^ ] public string DecryptData( string encryptedtext) encryptedtext = encryptedtext.Replace( " " , " +" ); int mod4 = encryptedtext.Length % 4 ; if (mod4 > 0 ) encryptedtext += new string ( ' =' , 4 - mod4); byte[] encryptedBytes = Convert.FromBase64String(encryptedtext); MemoryStream ms = new MemoryStream(); CryptoStream decStream = new CryptoStream(ms, tripleDESCryptoServiceProvider.CreateDecryptor(), CryptoStreamMode.Write); decStream.Write(encryptedBytes, 0 , encryptedBytes.Length); decStream.FlushFinalBlock(); return System.Text.Encoding.Unicode.GetString(ms.ToArray());
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •