日付の取得とhash値の算出

日付の取得とhash値の算出、ファイル名の変更(移動)

https://qiita.com/n0bisuke/items/dd28122d006c95c58f9c

  1. npm install date-utils でモジュールをインストール
  2. require('date-utils');でモジュール読み込み
  3. var dt = new Date();で日付を取得

https://qiita.com/kou_pg_0131/items/174aefd8f894fea4d11a

  1. var crypto = require(“crypto”); でモジュールを読み込み
  2. var dt = new Date();で日付を取得
  3. var hash = crypto.createHash(“md5”).update(dt + req.body.email).digest(“hex”);でハッシュ値を算出
const crypto = require('crypto');
// サポートされているハッシュアルゴリズムを確認
console.log(crypto.getHashes());
// `crypto.createHash('アルゴリズム名').update('文字列').digest('hex')`
crypto.createHash('md5').update(plainText).digest('hex') 
var hash = crypto.createHash("md5").update(dt + email).digest("hex");
var newfilename = "tmp/" + hash + ".gz";
fs.rename("tmp/" + filename, newfilename, (err) => {
      if (err) throw err;
});
  • 日付の取得とhash値の算出.1622446150.txt.gz
  • 最終更新: 2021/05/31 07:29
  • by 133.11.144.10