0
0

More than 1 year has passed since last update.

NodeでDESしてみる

Posted at

codesandbox.ioにSign up
dashboard>Create>Quick start>Node.js
index.jsに以下を貼り付け、CTRL+Sで保存すると、実行結果が表示される

const crypto = require("crypto");
const algorithm = "des-ecb";
const key = Buffer.from("mykeystr", "utf-8"); // 8バイト

const cipher = crypto.createCipheriv(algorithm, key, null);
const encrypted =
  cipher.update("暗号化対象文字列", "utf8", "hex") + cipher.final("hex");
console.log(encrypted);

const decipher = crypto.createDecipheriv(algorithm, key, null);
console.log(decipher.update(encrypted, "hex", "utf8") + decipher.final("utf8"));
0
0
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
0
0