1.0.0 • Published 2 years ago
capacitor-keystore-decrypt v1.0.0
capacitor-keystore-decrypt
This plugin has 2 methods. 1 for storing a plaintext key via Android Keystore. The other method is used to decode a byte array that in encrypted with aes-123 ECB encryption.
Storing the AES Key:
- The plugin takes a plaintext AES-128 key.
- It encrypts this key using an RSA public key generated and stored in the Android Keystore.
- The encrypted AES key is then stored securely, for example, in SharedPreferences.
Retrieving and Using the AES Key for Decryption:
- When you need to decrypt data, the plugin retrieves the encrypted AES key from where it was stored.
- It then decrypts this AES key using the RSA private key from the Android Keystore.
- The decrypted AES key is now available for use.
Decrypting Data:
- The plugin uses the decrypted AES key to decrypt data within the specified indices.
- It returns the decrypted data.
Install
npm install capacitor-keystore-decrypt
npx cap sync
API
storeKey(...)
storeKey(options: { alias: string; keyString: string; }) => Promise<void>
Method to securely store a key in the Android Keystore.
Param | Type | Description |
---|---|---|
options | { alias: string; keyString: string; } | - The options including the alias and keyString. |
decryptData(...)
decryptData(options: { alias: string; data: string; start: number; end: number; }) => Promise<{ data: string; }>
Method to decrypt a specific portion of a byte array using a key stored in the Android Keystore.
Param | Type | Description |
---|---|---|
options | { alias: string; data: string; start: number; end: number; } | - The options including the alias, data, start index, and end index. |
Returns: Promise<{ data: string; }>
1.0.0
2 years ago