SHA-256 Hash Generator

📄 Wiki page | 🕑 Last updated: Sep 13, 2022

A quick and clean online tool to generate a SHA-256 hash from a string.

Enter your input string:

🔨 More Tools


SHA-256 is a part of the set of SHA-2 cryptographic hash functions designed by NSA. Other novel function in SHA-2 family is SHA-512 (there are also truncated versions SHA-224, SHA-384, SHA-512/224, and SHA-512/256).

SHA-2 is based on Merkle–Damgård construction and is considered safe in most applications.

Examples of use in popular programming languages/environments:

Shell

sha256sum (part of the coreutils package) and openssl are two commonly used tools for this purpose:

echo -n "Hello" | sha256sum

echo -n "Hello" | openssl sha256

(echo -n omits the new line, otherwise the new line character will be included as an input to the hashing function)

JavaScript

Until recently, there was no native SHA support in browsers, but new SubtleCrypto interface (part of the Web Crypto API) can be used for this purpose:

async function sha1(message) {
    // encode as UTF-8
    const msgBuffer = new TextEncoder().encode(message);                    

    // hash the message
    const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);

    // convert ArrayBuffer to Array
    const hashArray = Array.from(new Uint8Array(hashBuffer));

    // convert bytes to hex string                  
    const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
    return hashHex;
}

sha1('Hello').then(res => console.log)

Alternatively, there are many 3rd party libs, like CryptoJS:

console.log(CryptoJS.256('Hello'));

Ask me anything / Suggestions

If you have any suggestions or questions (related to this or any other topic), feel free to contact me. ℹ️


If you find this site useful in any way, please consider supporting it.