Skip to content

Commit

Permalink
Merge pull request #793 from zshnb/fix-buffer-slice
Browse files Browse the repository at this point in the history
fix: use subarray instead of slice
  • Loading branch information
motdotla committed Jan 19, 2024
2 parents 8609b84 + 6979f94 commit 0489c7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@
node_modules

.DS_Store
.idea/
6 changes: 3 additions & 3 deletions lib/main.js
Expand Up @@ -241,9 +241,9 @@ function decrypt (encrypted, keyStr) {
const key = Buffer.from(keyStr.slice(-64), 'hex')
let ciphertext = Buffer.from(encrypted, 'base64')

const nonce = ciphertext.slice(0, 12)
const authTag = ciphertext.slice(-16)
ciphertext = ciphertext.slice(12, -16)
const nonce = ciphertext.subarray(0, 12)
const authTag = ciphertext.subarray(-16)
ciphertext = ciphertext.subarray(12, -16)

try {
const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)
Expand Down

0 comments on commit 0489c7d

Please sign in to comment.