13
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

node.jsでmd5を計算

Posted at

標準ライブラリのcryptoを使う。

// @flow
'use strict'
const crypto = require('crypto')

function md5hex(str /*: string */) {
  const md5 = crypto.createHash('md5')
  return md5.update(str, 'binary').digest('hex')
}

const hello = 'hello'
const hello2 = 'hello2'

console.log(md5hex(hello))
// 5d41402abc4b2a76b9719d911017c592
console.log(md5hex(hello2))
// 6e809cbda0732ac4845916a59016f954
13
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?