Skip to content

Commit 0489c7d

Browse files
authoredJan 19, 2024
Merge pull request #793 from zshnb/fix-buffer-slice
fix: use subarray instead of slice
2 parents 8609b84 + 6979f94 commit 0489c7d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
node_modules
66

77
.DS_Store
8+
.idea/

‎lib/main.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ function decrypt (encrypted, keyStr) {
241241
const key = Buffer.from(keyStr.slice(-64), 'hex')
242242
let ciphertext = Buffer.from(encrypted, 'base64')
243243

244-
const nonce = ciphertext.slice(0, 12)
245-
const authTag = ciphertext.slice(-16)
246-
ciphertext = ciphertext.slice(12, -16)
244+
const nonce = ciphertext.subarray(0, 12)
245+
const authTag = ciphertext.subarray(-16)
246+
ciphertext = ciphertext.subarray(12, -16)
247247

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

0 commit comments

Comments
 (0)
Please sign in to comment.