base64?
am trying to impliment rsa encryption in js but the atob and btoa methods just accepts string for some reason, so I did:
let encryptedArr = new Uint8Array((new BigInteger(new TextEncoder().encode('alo')).multiply(e)).mod(on).toByteArray())
^^ so that encrypted text array/bytes
when I do ```btoa(new TextDecoder().decode(encryptedArr))``` it just throws error
I found a stackoverflow post reguarding this error: https://stackoverflow.com/a/9853544/13327203
so now I replaced btoa with utf8_to_b64 and it don't throw the error anymore
this specificilly might have some error but there's another problem with TextDecoder and TextEncoder as well
I tried logging:
console.log(new TextEncoder().encode(new TextDecoder().decode(encryptedArr)) === encryptedArr);
but this retuns false...?
upon some debugging I found that the problem lies while converting the array to Uint8Array
Обсуждают сегодня