Skip to content

Instantly share code, notes, and snippets.

@EnetoJara
Created July 16, 2020 19:03
Show Gist options
  • Save EnetoJara/0479254bde2b3433436ec514d0e7a9b2 to your computer and use it in GitHub Desktop.
Save EnetoJara/0479254bde2b3433436ec514d0e7a9b2 to your computer and use it in GitHub Desktop.
function encryptText (toEncript) {
let i, k;
return getIv()
.then(iv => {
i = iv;
return getKey()
}).then(key => {
k = key;
const cipher = crypto.createCipheriv(algorithm, k, i);
const encrypted = cipher.update(toEncript, "utf8", "hex") + cipher.final("hex");
return encrypted;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment