react-native-simple-crypto
react-native-simple-crypto copied to clipboard
Android RSA.decrypt also expects a base64 input
This can't be right?
https://github.com/ghbutton/react-native-simple-crypto/blob/c338e2e3367c7907fa84999d5f65182385a69ac2/android/src/main/java/com/pedrouid/crypto/RSA.java#L155
The RSA.decrypt and RSA.decrypt64 both threat input as base64. Shouldn't the non base64 version just take the input string without decoding it first?
Yea that looks wrong
Actually I am not sure, will try to dig in a little more.
When we encrypt we store the intermediate as base64, which is why when we decrypt we assume the input is coming in as base64
That's what a decrypt64 function would be for. Another scenario is that this lib is used only for decryption of data encrypted somewhere else. So a binary input would be preferable. Especially one that does not need conversion between JS/Native. Maybe using ArrayBuffer or UINT8? Couldn't find anything in the docu which datatype is simply mapped and has no transfer overhead.
I think using ArrayBuffers everywhere would make more sense, or we could try to differentiate the input based on if it is a string or not similar to the SHA methods.
I think ArrayBuffer would need no translation between native an JS, if I am correct? (The RN module docs are not the best).
We have array buffers in other places, but we translate them to base64 in most cases. I dont think we can translate directly from javascript to native data types.
See: https://github.com/ghbutton/react-native-simple-crypto/blob/master/index.js#L76
There is an undocumented WritableArray that we could use. I'll link it here later.