pmcrypto
pmcrypto copied to clipboard
Refactor (and consider moving) base64 and utf8 utils
We should review if these utils are needed in the library, otherwise move them over to the clients monorepo.
Regardless, the following refactoring should be done:
- Remove the binary string variants
encodeUtf8
anddecodeUtf8
- Accept/return Uint8Arrays for base64 encoding/decoding
- Remove
encodeUtf8Base64
anddecodeUtf8Base64
(they can just chain two functions)
decodeBase64
(or base64ToBytes/Array
) should return a Uint8Array, and then utf8BytesToString
should take a Uint8Array
and return a string, so that utf8BytesToString ∘ base64ToBytes == decodeUtf8Base64
.
And then if binary strings are needed in some cases, binaryStringToArray
/ arrayToBinaryString
can be used.
just use scure-base which is independently audited, minimal, 0-dep base64 lib.