密碼學筆記
search
Ctrlk
  • Introduction
  • 數論相關
  • 大數轉換
  • Big Endian & small Endian
  • MD5
  • RSA
  • DSA
  • AES
  • SHA256
  • RIPEMD
  • ECDSA & ECDH
  • OpenSSL 實用指令
  • Crypto module
  • Byte Padding
gitbookPowered by GitBook
block-quoteOn this pagechevron-down

Crypto module

hashtag
Argon2

https://github.com/ranisalt/node-argon2arrow-up-right

hashtag
Bcrypt

https://github.com/kelektiv/node.bcrypt.jsarrow-up-right

hashtag
sjcl (By standford)

https://github.com/bitwiseshiftleft/sjcl/tree/3668e639bc78e910815f501d55458e968845edc2arrow-up-right

hashtag
PyCrypto (python crypto module)

https://pycryptodome.readthedocs.io/en/latest/src/introduction.htmlarrow-up-right

hashtag
Web Crypto API

https://www.w3.org/TR/WebCryptoAPI/#crypto-interfacearrow-up-right

https://developer.mozilla.org/en-US/docs/Web/API/Cryptoarrow-up-right

https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digestarrow-up-right

PreviousOpenSSL 實用指令chevron-leftNextByte Paddingchevron-right

Last updated 3 years ago

  • Argon2
  • Bcrypt
  • sjcl (By standford)
  • PyCrypto (python crypto module)
  • Web Crypto API
async function sha256(message) {
    const msgBuffer = new TextEncoder('utf-8').encode(message);                     // encode as UTF-8
    const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);            // hash the message
    const hashArray = Array.from(new Uint8Array(hashBuffer));                       // convert ArrayBuffer to Array
    const hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join(''); // convert bytes to hex string
    return hashHex;
}

sha256('abc').then(hash => console.log(hash));

(async function() {
    const hash = await sha256('abc');
}());