Skip to content

Commit

Permalink
fix: use subarray instead of slice
Browse files Browse the repository at this point in the history
  • Loading branch information
zshnb committed Dec 30, 2023
1 parent 5d00dd9 commit 6979f94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
node_modules

.DS_Store
.idea/
6 changes: 3 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,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 6979f94

Please sign in to comment.