Skip to content

Backbase/mobile-encryption-accelerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Encryption Accelerator for mobile projects

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published