SHA 256 hash String - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:SHA1

Description

SHA 256 hash String

Demo Code


using System.Text;
using System.Security.Cryptography;
using System.IO;/* w  w w.  j a  va2 s .  c om*/
using System;
using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class Main{
        public static string SHA256(string sourceStr)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(sourceStr);
            SHA256Managed managed = new SHA256Managed();
            byte[] inArray = managed.ComputeHash(bytes);
            managed.Clear();
            return Convert.ToBase64String(inArray);
        }
}

Related Tutorials