Next: asp.net,c# encryption and decryption string of the use of detailed, a netizen asked:
Which means that the encrypted data is no longer:n8laahmftsaqgaf3+rufng==
Hope encryptedstring is "120387789370480938409832840923492384028934...";
Of course, the numbers above are random knocks.
So how to achieve pure numbers??
The idea is simple, just turn the character into a ASCLL code. such as a:97, =:61;
Then encryptedstring can become 97 81 61 33 44 55 ...;
But if they are together, they become 978161334455.
Here's the question: How do I know that 97 is a, not 9,7?
If you know that computers are binary representations, you should be able to think that we can turn 97 into 0, 1 forms.
The above number can then become 0001 0011 011 001.
OK, we also have 2,3,4,5,6,7,8,9, not used, so we can use any character to separate.
For example, turn the number above into 0001 2 0011 2 011 2 2 001
Of course, the numbers can be coded, but 3,4,5,6,7,8,9 are wasted,
So here we should not choose 2, it is best to choose the 9 system. What do you mean? 9 into the system?
Yes, 9:0,1,2,3,4,5,6,7,8,10. of which 10 represents 9, then 9 as the separator symbol;
Unfortunately, C # code does not support 9, so it's easy to choose 8.
The code is as follows:
Copy Code code as follows:
<summary>
Converts a string into a numeric string
</summary>
<param name= "Value" ></param>
<returns></returns>
private static string Convertstringtonumbers (string value)
{
StringBuilder sb = new StringBuilder ();
foreach (char c in value)
{
int cascil = (int) c;
Sb. Append (Convert.ToString (c, 8) + "9");
}
Return SB. ToString ();
}
String encryptednumberstring = Convertstringtonumbers (encryptedstring);
Encryptednumberstring =11697091549101914191109115910691649123
91019121914791419146963953912291259106915691479759759
Well, it's been successfully separated, and the rest is to extract the characters from the string that makes up the numbers.
The code is as follows:
Copy Code code as follows:
<summary>
Converts a numeric string to a normal character string
</summary>
<param name= "Value" ></param>
<returns></returns>
private static string Convertnumberstostring (string value)
{
string[] Splitint = value. Split (new char[] {' 9 '}, stringsplitoptions.removeemptyentries);
var splitchars = Splitint.select (S => convert.tochar (
Convert.ToInt32 (S, 8)
). ToString ());
return string. Join ("", splitchars);
}
The results are as follows:
The rest depends on the reader's own play ...