Answers for "sha256 hash c#"

C#
2

c# string to sha256

public static String sha256_hash(String value) {
  StringBuilder Sb = new StringBuilder();

  using (SHA256 hash = SHA256Managed.Create()) {
    Encoding enc = Encoding.UTF8;
    Byte[] result = hash.ComputeHash(enc.GetBytes(value));

    foreach (Byte b in result)
      Sb.Append(b.ToString("x2"));
  }

  return Sb.ToString();
}
Posted by: Guest on March-19-2021
0

sha256

# Python program to find SHA256 hexadecimal hash string of a file
import hashlib
 
filename = input("Enter the input file name: ")
with open(filename,"rb") as f:
    bytes = f.read() # read entire file as bytes
    readable_hash = hashlib.sha256(bytes).hexdigest();
    print(readable_hash)
Posted by: Guest on March-17-2022

C# Answers by Framework

Browse Popular Code Answers by Language