Skip to content

Commit 4560b7d

Browse files
committed
fix bug in decryptUint
1 parent e780b32 commit 4560b7d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libs/crypto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ export function decryptUint(ciphertext: bigint, userKey: string) {
113113
// Decrypt the cipher
114114
const decryptedMessage = decrypt(Buffer.from(userKey, "hex"), r, cipher)
115115

116-
return parseInt(decryptedMessage.toString("hex"), block_size)
116+
return BigInt("0x" + decryptedMessage.toString("hex"))
117117
}
118118

119119
export function decryptString(ciphertext: Array<bigint>, userKey: string) {
120120
let decryptedStr = new Array<number>(ciphertext.length)
121121

122122
for (let i = 0; i < ciphertext.length; i++) {
123-
decryptedStr[i] = decryptUint(ciphertext[i], userKey)
123+
decryptedStr[i] = Number(decryptUint(ciphertext[i], userKey))
124124
}
125125

126126
let decoder = new TextDecoder()

0 commit comments

Comments
 (0)