Quelle bibliothèque rsa recommandée pour la plateforme «react native»?

Quelle bibliothèque rsa est recommandée pour la plate-forme “react native” avec une prise en charge Android?

Je vous remercie

MODIFIER:

J’ai essayé de react-native-rsa :

 var encrypted = ''; try { var RSAKey = require('react-native-rsa'); const bits = 1024; const exponent = '10001'; var rsa = new RSAKey(); rsa.generate(bits, exponent); var publicKey = rsa.getPublicSsortingng(); var privateKey = rsa.getPrivateSsortingng(); } catch (error) { console.log(1); console.log(error); } try { rsa = new RSAKey(); rsa.setPrivateSsortingng(privateKey); var originText = 'Test 123 Test 321'; encrypted = rsa.encrypt(originText); } catch (error) { console.log(2); console.log(error); } try { rsa = new RSAKey(); rsa.setPublicSsortingng(publicKey); var decrypted = rsa.decrypt(encrypted); console.log(decrypted); } catch (error) { console.log(3); console.log(error); } 

Mais j’ai eu cette erreur:

 I/ReactNativeJS( 9238): 3 I/ReactNativeJS( 9238): { [TypeError: null is not an object (evaluating 'e.bitLength')] I/ReactNativeJS( 9238): line: 96781, I/ReactNativeJS( 9238): column: 8, I/ReactNativeJS( 9238): sourceURL: 'http://10.0.3.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false' } 

Essayez de react-native-rsa , il est simple à utiliser et supportera la plate-forme Android.

Première bibliothèque d’installation à l’aide de Npm:

npm install react-native-rsa

Générer des clés RSA:

 var RSAKey = require('react-native-rsa'); const bits = 1024; const exponent = '10001'; // must be a ssortingng var rsa = new RSAKey(); var r = rsa.generate(bits, exponent); var publicKey = rsa.RSAGetPublicSsortingng(); // return json encoded ssortingng var privateKey = rsa.RSAGetPrivateSsortingng(); // return json encoded ssortingng 

Encript:

 var rsa = new RSAKey(); rsa.setPublicSsortingng(publicKey); var originText = 'sample Ssortingng Value'; var encrypted = rsa.encrypt(originText); 

Decript:

 rsa.setPrivateSsortingng(privateKey); var decrypted = rsa.decrypt(encrypted); // decrypted == originText 

Référence: https://www.npmjs.com/package/react-native-rsa