2.4.2 • Published 3 months ago

react-native-fast-rsa v2.4.2

Weekly downloads
112
License
MIT
Repository
github
Last release
3 months ago

react-native-fast-rsa

Android iOS

Getting started

$ npm install react-native-fast-rsa --save

JSI

If you want to use with JSI instead of NativeModules you need to set

import RSA from "react-native-fast-rsa";

RSA.useJSI = true;

if you need to use generate methods it is a good idea to disable it, because for now JSI will block your UI but it is faster compared to NativeModules

Usage

export interface PCKS12KeyPair {
  publicKey: string;
  privateKey: string;
  certificate: string;
}
export interface KeyPair {
  publicKey: string;
  privateKey: string;
}

export enum Hash {
  MD5 = 0,
  SHA1 = 1,
  SHA224 = 2,
  SHA256 = 3,
  SHA384 = 4,
  SHA512 = 5,
}

export enum PEMCipher {
  DES = 0,
  D3DES = 1,
  AES128 = 2,
  AES192 = 3,
  AES256 = 4,
}

export enum SaltLength {
  AUTO = 0,
  EQUALS_HASH = 1,
}

class RSA {
  static convertJWKToPrivateKey(data: any, keyId: string): Promise<string>
  static convertJWKToPublicKey(data: any, keyId: string): Promise<string>

  static convertKeyPairToPKCS12(privateKey: string, certificate: string, password: string): Promise<string>
  static convertPKCS12ToKeyPair(pkcs12: string, password: string,): Promise<PCKS12KeyPair>

  static convertPrivateKeyToPKCS8(privateKey: string,): Promise<string>
  static convertPrivateKeyToPKCS1(privateKey: string): Promise<string>
  static convertPrivateKeyToJWK(privateKey: string): Promise<any>
  static convertPrivateKeyToPublicKey(privateKey: string): Promise<string>

  static convertPublicKeyToPKIX(publicKey: string): Promise<string>
  static convertPublicKeyToPKCS1(publicKey: string): Promise<string>
  static convertPublicKeyToJWK(publicKey: string): Promise<any>

  static decryptPrivateKey(privateKeyEncrypted: string, password: string,): Promise<string>
  static encryptPrivateKey(privateKey: string, password: string, cipherName: Cipher): Promise<string>

  static decryptOAEP(message: string, label: string, hashName: Hash, privateKey: string): Promise<string>
  static decryptPKCS1v15(message: string, privateKey: string,): Promise<string>

  static encryptOAEP(message: string,label: string, hashName: Hash, publicKey: string): Promise<string>
  static encryptPKCS1v15(message: string, publicKey: string): Promise<string>

  static signPSS(message: string, hashName: Hash, saltLengthName: SaltLength, privateKey: string): Promise<string>
  static signPKCS1v15(message: string, hashName: Hash, privateKey: string): Promise<string>

  static verifyPSS(signature: string, message: string, hashName: Hash, saltLengthName: SaltLength, publicKey: string): Promise<boolean>
  static verifyPKCS1v15(signature: string, message: string, hashName: Hash, publicKey: string): Promise<boolean>

  static hash(message: string, name: Hash): Promise<string>
  static base64(message: string): Promise<string>

  static generate(bits: number): Promise<KeyPair>
}

Native Code

the native library is made in Golang for faster performance

https://github.com/jerson/rsa-mobile

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

2.4.2

3 months ago

2.4.1

5 months ago

2.4.0

7 months ago

2.3.4

2 years ago

2.3.6

2 years ago

2.3.5

2 years ago

2.3.3

2 years ago

2.3.0

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.2.5

2 years ago

2.2.4

2 years ago

2.2.1

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.0.0-rc1

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago