SHA-3 code examples
SHA3-256 of the string "hello world" in every common language. Every snippet should print 644bcc7e564373040999aac89e7622f3ca71fba1d972fd94a31c3bfbf24e3938.
Python
import hashlib
print(hashlib.sha3_256(b"hello world").hexdigest())
print(hashlib.shake_256(b"hello world").hexdigest(32)) # SHAKE256, 32-byte output
Node.js
import { createHash } from "node:crypto";
console.log(createHash("sha3-256").update("hello world").digest("hex"));
JavaScript in the browser
The Web Crypto API does not include SHA-3, so use a library such as js-sha3 (the one this site uses):
import { sha3_256, keccak256 } from "js-sha3";
sha3_256("hello world"); // NIST SHA3-256
keccak256("hello world"); // Ethereum Keccak-256
Go
package main
import (
"crypto/sha3" // Go 1.24+; older versions: golang.org/x/crypto/sha3
"fmt"
)
func main() {
fmt.Printf("%x", sha3.Sum256([]byte("hello world")))
}
Rust
// Cargo.toml: sha3 = "0.10", hex = "0.4"
use sha3::{Digest, Sha3_256};
fn main() {
let hash = Sha3_256::digest(b"hello world");
println!("{}", hex::encode(hash));
}
Java
import java.security.MessageDigest;
import java.util.HexFormat;
byte[] h = MessageDigest.getInstance("SHA3-256")
.digest("hello world".getBytes(java.nio.charset.StandardCharsets.UTF_8));
System.out.println(HexFormat.of().formatHex(h)); // Java 17+
PHP
<?php
echo hash('sha3-256', 'hello world');
C# (.NET 8+)
using System.Security.Cryptography;
using System.Text;
if (SHA3_256.IsSupported)
{
byte[] h = SHA3_256.HashData(Encoding.UTF8.GetBytes("hello world"));
Console.WriteLine(Convert.ToHexString(h).ToLowerInvariant());
}
OpenSSL command line
printf "hello world" | openssl dgst -sha3-256
openssl dgst -sha3-512 myfile.bin
Need Ethereum-compatible hashes instead? See SHA-3 vs Keccak-256.
Own sha3.si
A short, exact-match domain for one of the world's core cryptographic standards. Ideal for a security, cryptography, blockchain or developer-tools brand.
Buy now or make an offer Why this name