crypto

crypto


Node.js

const crypto = require('crypto')

const hash = crypto.createHash('sha256').update(Buffer.from('hello')).digest()

console.log(hash.toString('hex'))

Output

2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

Go

package main

import (
    "crypto/sha256"
    "encoding/hex"
    "fmt"
)

func main() {
    hash := sha256.Sum256([]byte("hello"))

    fmt.Println(hex.EncodeToString(hash[:]))
}

Output

2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824