Last active
June 27, 2017 16:49
-
-
Save SangHakLee/04431a9b38f4cbe62d7de0416a5983fd to your computer and use it in GitHub Desktop.
DES 암호화
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto') | |
/** | |
* | |
* @param {String} plaintext (64bit 8Byte) | |
* @param {String} key (56bit 7Byte) | |
* | |
* @return {String} ciphertext | |
*/ | |
const DES = (plaintext, key) => { | |
let cipher = crypto.createCipher('des', key) | |
let ciphertext = cipher.update(plaintext, 'utf8', 'hex') | |
ciphertext += cipher.final('hex') | |
return ciphertext | |
} | |
console.log( DES('hak', '1234567') ) // | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment