Encryption using sha without key in asp.net

Task: Encryption using SHA without key in asp.net.

Description: Encryption using SHA in asp.net and c#. Using below code we can generate message digest. In Web technology we need to save password of user, for this we can use this one. It is one way encryption, we can't decrypt it back. Here we Encrypt data without key, for encrypt using key see here.



using System;
using System.Security.Cryptography;

using System.Text;

    private void shaEncryption(string plaintext)
    {
        byte[] data = ASCIIEncoding.ASCII.GetBytes(plaintext);
        byte[] result;
        SHA1 sha = new SHA1CryptoServiceProvider();
       
        result = sha.ComputeHash(data);
        lblencrypt.Text = "<br/>SHA Output : <br/>" + Convert.ToBase64String(result);

    }
 

No comments:

Post a Comment