private string
Decrypt
(
string
cipherText
)
{
cipherText = cipherText.
Replace
(
" "
,
"+"
);
byte
[]
cipherBytes =
Convert
.
FromBase64String
(cipherText);
Aes
encryptor =
Aes
.
Create
();
Rfc2898DeriveBytes
pdb =
new
Rfc2898DeriveBytes
(EncryptionKey,
new byte
[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4e, 0x65, 0x64, 0x76 });
encryptor
.Key =
pdb.
GetBytes
(32);
encryptor
.IV =
pdb.
GetBytes
(16);
MemoryStream
ms =
new
MemoryStream
();
CryptoStream
cs =
new
CryptoStream
(ms, encryptor.
CreateDecryptor
(),
CryptoStreamMode
.Write);
cs.
Write
(clearBytes, 0, clearBytes.Length);
cs.
Close
();
cipherText =
Encoding
.Unicode.
GetString
(ms.
ToArray
());
return
cipherText;
}