Replies: 1 comment
-
Turns out the issue was with tob64, I should've written a custom function function uint8ArrayToBase64(arr, options) {
const lookup =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
let result = ''
let i = 0
for (; i + 2 < arr.length; i += 3) {
const triplet = (arr[i] << 16) + (arr[i + 1] << 8) + arr[i + 2]
result +=
lookup[(triplet >> 18) & 63] +
lookup[(triplet >> 12) & 63] +
lookup[(triplet >> 6) & 63] +
lookup[triplet & 63]
}
if (i + 2 === arr.length) {
const triplet = (arr[i] << 16) + (arr[i + 1] << 8)
result +=
lookup[(triplet >> 18) & 63] +
lookup[(triplet >> 12) & 63] +
lookup[(triplet >> 6) & 63] +
'='
} else if (i + 1 === arr.length) {
const triplet = arr[i] << 16
result += lookup[(triplet >> 18) & 63] + lookup[(triplet >> 12) & 63] + '=='
}
return result
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Thanks for the awesome library!
I'm currently working on replicating the following code
I've converted it into the following, but when I attempt to decode this, I get
ERR_OSSL_EVP_WRONG_FINAL_BLOCK_LENGTH
. I believe this is because I haven't implemented PKCS7 correctly.Looking at the source code, this seems pretty similar to the PKCS5, so I also tried the following, but that didn't work either.
Do you have any advice?
Beta Was this translation helpful? Give feedback.
All reactions