Skip to content

Commit 6979f94

Browse files
committedDec 30, 2023
fix: use subarray instead of slice
1 parent 5d00dd9 commit 6979f94

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
@@ -237,9 +237,9 @@ function decrypt (encrypted, keyStr) {
237237
const key = Buffer.from(keyStr.slice(-64), 'hex')
238238
let ciphertext = Buffer.from(encrypted, 'base64')
239239

240-
const nonce = ciphertext.slice(0, 12)
241-
const authTag = ciphertext.slice(-16)
242-
ciphertext = ciphertext.slice(12, -16)
240+
const nonce = ciphertext.subarray(0, 12)
241+
const authTag = ciphertext.subarray(-16)
242+
ciphertext = ciphertext.subarray(12, -16)
243243

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

0 commit comments

Comments
 (0)
Please sign in to comment.