SHA256 hash calculator

SHA256 file checksum

Sample SHA256 code

SHA256 in PHP

$s = ''; // String to hash
$hash = hash('sha256', $s); // hash string
echo $hash; // eb744e5e9...

// PHP also support hash file with function
$file = '/path/to/file';
$hash = hash_file('sha256', $file);
echo $hash; // SHA256 hash checksum of $file
// but you can see, hash_file function look like:
$s = file_get_contents($file);
$hash = hash('sha256', $s);

SHA256 in Javascript

<script src=""></script>
    var s, hash;
    s = ""; // String to hash
    hash = SHA256(s); // hash string
    console.log(hash); // eb744e5e9...
    // NOTE: function SHA256() is from, you can download it to your project
    // is using this

SHA256 in C#

using System;
using System.Security.Cryptography;
using System.Text;
// ...
String s = ""; // String to hash

StringBuilder Sb = new StringBuilder();
using (SHA256 hash = SHA256Managed.Create()) {
    Encoding enc = Encoding.UTF8;
    Byte[] result = hash.ComputeHash(enc.GetBytes(s));
    foreach (Byte b in result) {

    String encoded = Sb.ToString();

SHA256 in Python

import hashlib
hash_object = hashlib.sha256(b'')
hex_dig = hash_object.hexdigest()

SHA256 in Java

String text = "";
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(text.getBytes(StandardCharsets.UTF_8));

String encoded = Base64.getEncoder().encodeToString(hash); // Java 8

// Or...
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < hash.length; i++) {
    String hex = Integer.toHexString(0xff & hash[i]);
    if(hex.length() == 1) hexString.append('0');
String encoded = hexString.toString();

SHA256 in Ruby

require 'digest'
Digest::SHA256.hexdigest ''    #=> "eb744e5e9..."

# hash a file
sha256 = Digest::SHA256.file 'testfile'
What is SHA256?

SHA (Secure Hash Algorithm) is one of a number of many cryptographic hash functions. A cryptographic hash is like a signature for a text or a data file. SHA256 algorithm generates an almost-unique, fixed size 256-bit (32-byte) hash. This is a one way function – it cannot be decrypted back. It makes it suitable for password validation, digital signatures, challenge hash authentication, anti-tamper, ...

Is SHA256 used for mining Bitcoin?

Yes. SHA256 is the actual function used for mining Bitcoin and many other cryptocurrencies.

Can SHA256 be decrypted?

NO. SHA256 is a one-way hashing function, not an encryption function.

Is SHA256 better than MD5?

Both of SHA256 and MD5 are one-way hashing functions. MD5 is faster but has 128-bit output, while SHA256 has 256-bit output. So, SHA256 is better than MD5.

How long is a SHA256 hash?

A SHA256 is 256 bits long (as its name indicates). If you are using an hexadecimal representation, it will take 64 digits.
So, if you want to store it into your DB, you need a varchar(64), or a char(64), as the length is always the same, not varying at all.