利用 Enterprise Library 改善你的应用系统6——Cryptograph Block
Hash 加密与比较的例子:
加密
byte[] value2Encrypt = Encoding.unicode.GetBytes("password");
byte[] encryptedContents =
Cryptographer.EncryptSymmetric("symmProvider",value2Encrypt);
Array.Clear(value2Encrypt,0,value2Encrypt.Length);
string encrytedText = Convert.ToBase64String(encryptecontents);
解密
byte[] decryptedContents = Encoding.Unicode.GetBytes(yourPwd);
bool matched =
Cryptographer.CompareHash("hashProvider",value2Hash,existingHashValue);
Array.Clear(value2Hash,0,value2Hash.Length);