itinance/react-native-sha256

[Feature request] Raw & Base64 support

halaei opened this issue · 3 comments

Is it possible to provide raw, base64, and/or base64url output support as well. This is will be handy for implementing OAuth clients, for example.

I find this simple snippet from stackoverflow to convert hex to base64:

btoa("4142434445464748494a4b4c4d4e4f505152535455565758595a".match(/\w{2}/g).map(function(a){return String.fromCharCode(parseInt(a, 16));} ).join("")) 

It is going to fix my problem.
Thanks.

sevaa commented

The following works for me as of React Native 0.70.5:

function hexToBase64(s:string)
{
  return Buffer.from(s, 'hex').toString('base64');
}

it would still be nice to have support for base64 straight from the module.