https://github.com/backbase/mobile-encryption-accelerator
Encryption Accelerator for mobile projects
https://github.com/backbase/mobile-encryption-accelerator
Last synced: 11 months ago
JSON representation
Encryption Accelerator for mobile projects
- Host: GitHub
- URL: https://github.com/backbase/mobile-encryption-accelerator
- Owner: Backbase
- Created: 2025-01-07T13:22:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-07T13:25:08.000Z (about 1 year ago)
- Last Synced: 2025-03-19T12:52:38.108Z (11 months ago)
- Language: Swift
- Size: 104 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mobile Encryption Accelerator
This accelerator provides functionalities for RSA encryption and decryption. It allows you to encrypt data using either a public key provided by the Identity Realm or a public key provided by any other means, and decrypt data encrypted with the corresponding private key.
## Features
- Generate RSA key pairs
- Encrypt data using a public key
- Decrypt data using a private key
- Supports different key sizes (512, 1024, 2048, 3072, 4096 bits)
- Allows specifying a custom cipher type
## Constructors
- `BBRSACryptor(keySize: KeySize)`: Creates a new instance with a randomly generated key pair of the specified size.
- `BBRSACryptor(publicKey: String, privateKey: String)`: Creates a new instance with the provided public and private keys (Base64 encoded).
- `BBRSACryptor(keySize: KeySize, cipherType: String)`: Creates a new instance with a randomly generated key pair of the specified size and cipher type.
- `BBRSACryptor(publicKey: String, privateKey: String, cipherType: String)`: Creates a new instance with the provided public and private keys (Base64 encoded) and cipher type.
## Methods
- `getPublicKey()`: Returns the public key as a Base64 encoded string.
- `getPrivateKey()`: Returns the private key as a Base64 encoded string.
- `encrypt(message: String)`: Encrypts the given message using the public key.
- `encrypt(message: String, publicKey: String)`: Encrypts the given message using the provided public key (Base64 encoded).
- `decrypt(encryptedMessage: String)`: Decrypts the given encrypted message using the private key.
- `decrypt(encryptedMessage: String, privateKey: String)`: Decrypts the given encrypted message using the provided private key (Base64 encoded).
## Example Usage
```
// Generate a new key pair with a key size of 2048 bits
val cryptor = BBRSACryptor.create(BBRSACryptor.KeySize.BIT_2048)
// Get the public and private keys
val publicKey = cryptor.getPublicKey()
val privateKey = cryptor.getPrivateKey()
// Encrypt a message using the public key
val message = "This is a secret message"
val encryptedMessage = cryptor.encrypt(message)
// Decrypt the encrypted message using the private key
val decryptedMessage = cryptor.decrypt(encryptedMessage)
println(decryptedMessage) // Output: This is a secret message
```
## Important Notes
- Ensure that the provided public and private keys are valid and compatible with each other.
- Choose an appropriate key size based on your security requirements.
- This library uses Base64 encoding for public and private keys.