.NET Framework Developer Center > .NET Development Forums > .NET Base Class Library > Encryption/Decryption using SHA - 256 Algorithm
Ask a questionAsk a question
 

General DiscussionEncryption/Decryption using SHA - 256 Algorithm

  • Thursday, November 05, 2009 5:49 AMKamal Presna Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    How to decrypt a hashed string using SHA - 256 algorithm?

    Code i used for encrypting as follows:

     byte[] data = Encoding.UTF8.GetBytes(plainMessage);
     HashAlgorithm sha = new SHA256Managed();
     byte[] encryptedBytes = sha.TransformFinalBlock(data, 0, data.Length);
     return Convert.ToBase64String(sha.Hash);

    Thanks in advance
    Kamal

All Replies

  • Thursday, November 05, 2009 6:30 AMRay M_ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hasing and encryption are two different processes, hasing is a one way process once the data is hashed there is no way to recover the original data from the hash, you could see it as throwing a banana into a blender, you'll albe to determine it was a banana by looking at the goo thats left but you'll never be able to reconstruct the original banana. 
  • Thursday, November 05, 2009 9:55 AMKamal Presna Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    OOPS! I never thought that before. Thanks ray!

    I like the way you have explained.

    Then, What is the difference between Hashing and Encrytion?

  • Thursday, November 05, 2009 2:29 PMRay M_ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    See the links i gave you, encryption protects data from prying eyes, hashing creates a small (128/256 bit) fingerprint of a larger chunk of data.