2
2

More than 3 years have passed since last update.

CloudFunctionsで文字列をハッシュ化したいならcrypto

Last updated at Posted at 2020-05-02

複雑な家庭の事情でどうしてもfirebase上のアプリで任意の値をMD5にしなければならなかったのでメモ。

nuxt上でなんか処理しようかとおもったがいいライブラリがなく、CloudFunctionsならNode.jsなのでcryptoモジュールが使えることに気づいた。

/functions/index.js
const crypto = require('crypto');
const hash_ni_shitai_value = "ハッシュ化したい値";
const hash_ni_natta_value = crypto.createHash('md5').update(hash_ni_shitai_value).digest('hex');
return hash_ni_natta_value;

phpのmd5($str)ほど短くはないけどこれが最短なのでは。

2
2
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
2
2