SHA-1 Hash Generator

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

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

Enter your input string:

🔨 More Tools


SHA-1 (Secure Hash Algorithm 1) is a hash function designed by NSA, which produces a 160-bit (20-byte) hash value (a message digest).

It's cryptographically broken, and it it's generally recommended to remove SHA-1 from applications, and replace it with SHA-2 or SHA-3.

SHA-1 is still widely used, mostly for data integrity purposes (most notably, revision control systems - Git, Mercurial, Monotone).

Examples of use in popular programming languages/environments:

Shell

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

echo -n "Hello" | sha1sum

echo -n "Hello" | openssl sha1

(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-1', 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.SHA1('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.