Skip to content

Instantly share code, notes, and snippets.

@hypnguyen1209
Last active May 5, 2021 05:46
Show Gist options
  • Save hypnguyen1209/279d36c7dff75a0f9103beaf0512901e to your computer and use it in GitHub Desktop.
Save hypnguyen1209/279d36c7dff75a0f9103beaf0512901e to your computer and use it in GitHub Desktop.
const CryptoJS = require('crypto-js')
const e = {
message: "test phát nữa",
clientId: null, // type: Number
toid: "" // type: String
}
const getParam = e => {
const t = CryptoJS.enc.Base64.parse('kMj/NDripXEt4d7Fm9PlwQ==')
const iv = CryptoJS.enc.Hex.parse('00000000000000000000000000000000')
const mode = CryptoJS.mode.CBC
const padding = CryptoJS.pad.Pkcs7
return CryptoJS.AES.encrypt(JSON.stringify(e), t, {
iv, mode, padding
}).ciphertext.toString(CryptoJS.enc.Base64)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment