Skip to content

Commit

Permalink
var instead of let
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirco Haug authored and Mirco Haug committed Jul 29, 2020
1 parent 96fbc45 commit fb5681d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ function encryptString (cleartext, keyphrase) {
const iv = crypto.randomBytes(16)

const cipher = crypto.createCipheriv('aes256', key, iv)
let cipherText = cipher.update(cleartext, outerEncoding, innerEncoding)
var cipherText = cipher.update(cleartext, outerEncoding, innerEncoding)
cipherText += cipher.final(innerEncoding)
return Buffer.from(iv, 'binary').toString('base64') + '@' + cipherText.toString()
}

function decryptString (cipherText, keyphrases) {
const [encodedVi, encryptedText] = cipherText.split('@')
const iv = Buffer.from(encodedVi, 'base64')
let lastError = null
var lastError = null
for (const keyphrase of keyphrases) {
try {
const key = crypto
Expand All @@ -326,7 +326,7 @@ function decryptString (cipherText, keyphrases) {
.digest()

const decipher = crypto.createDecipheriv('aes256', key, iv)
let clearText = decipher.update(encryptedText, innerEncoding, outerEncoding)
var clearText = decipher.update(encryptedText, innerEncoding, outerEncoding)
clearText += decipher.final(outerEncoding)
return clearText.toString()
} catch (e) {
Expand Down

0 comments on commit fb5681d

Please sign in to comment.