Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

need help in DES Decryption

$
0
0

I am trying to decrypt an encoded encrypted value. But it is not returning the unencrypted value. I am using DES algorithm.

Can someone please help me with this?

Decryption Code:

publicstaticstring Decrypt(string encryptedString)

{

byte[] bytes = CreateKey();

if (String.IsNullOrEmpty(encryptedString))

{

thrownewArgumentNullException

("The string which needs to be decrypted can not be null.");

}

DESCryptoServiceProvider cryptoProvider = newDESCryptoServiceProvider();

MemoryStream memoryStream =newMemoryStream

(Convert.FromBase64String(encryptedString));

cryptoProvider.Padding =PaddingMode.Zeros;

CryptoStream cryptoStream =newCryptoStream(memoryStream,

cryptoProvider.CreateDecryptor(bytes, bytes),CryptoStreamMode.Read);

StreamReader reader =newStreamReader(cryptoStream);

return reader.ReadToEnd();

}


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>