开发者

How I can encrypt a string in c #?

开发者 https://www.devze.com 2023-01-05 16:02 出处:网络
MD5 md5 = MD5.Create(); byte[] Ostring = System.Text.Encoding.UTF8.GetBytes(\"original string\"); byte[] hashMD5 = md5.ComputeHAsh(Ostring);
MD5 md5 = MD5.Create();
byte[] Ostring = System.Text.Encoding.UTF8.GetBytes("original string");
byte[] hashMD5 = md5.ComputeHAsh(Ostring);
StringBuilder sb = new StringBuilder();
for (int i=0; i<hashMD5.Length; i++)
{
   sb.Append(hashMD5[i].ToString("X2"));
}
stri开发者_运维知识库ng strMD5 = sb.ToString();

the value of strMD5 I want encrypt it, using the algorithm RSA with a key in DER format "file: aa.key"

How I can do it in c #?


Your code only hashes a string. Hashes are asymmetrical, one-way only - you cannot "unhash" something.

A good, complete example of symmetrical string encryption is here: http://www.obviex.com/samples/Encryption.aspx.


I show an extended example here

The context in this sample was to encrypt a query string using c#

0

精彩评论

暂无评论...
验证码 换一张
取 消