RSA cryptography
Encrypt, decrypt, sign and check signatures RSA cryptography extension for App Inventor and compatibles.
Description
The RSA cryptography Java extension is used for RSA asymmetric cryptography, to encrypt, decrypt, sign, and verify signatures using RSA. The program is designed to work with App Inventor compatibles and is distributed under the GNU General Public License version.
Developed by ©Eric M. Kok (appsbeheerder).
Downloads
Extension
 RSA cryptography extension .aix  (current version 4.3.12)
Last update 24 February 2024
Example App
RSA cryptography repository
Parameters and Data Types
Keys
GenerateKeys

Parameters:
keyLength
(Type: int)  The length of the RSA key to be generated. Should be at least 8 times larger than the length of the text to be encrypted.

Event KeysGenerated called:
KeysGenerated
 Raised after key generation.successful
(Type: boolean)  TRUE if keys are successfully generated.response
(Type: String)  Response message after key generation.privateKey
(Type: String)  Private key in Base64 format.publicKey
(Type: String)  Public key in Base64 format.keyLength
(Type: int)  Length of the generated key in bits.
keyLength
 Function:
 Returns the length of the key used in the last key generation.
 Returns:
int
 Length of the key in bits.
PublicKey
 Function:
 Returns the public key in Base64
PrivateKey
 Function:
 Returns the private key in Base64
EmptyKeys
 Function:
 Empties the public and private keys (sets them to null).
Encryption and Decryption
Encrypt and Async Encrypt

Parameters:
string
(Type: String)  The text to be encrypted.publicKey
(Type: String)  Public key in Base64 format.cipherAlgorithm
(Type: String)  The cipher algorithm to be used for encryption.

Function:
 Encrypts the input string with the provided public key using the specified cipher algorithm.
 Returns:
String
 Encrypted text in Base64 format.

Event:
 Event
Encrypted
 Raised after async encryption. data
(Type: string)  Encrypted data in Base64.
Decrypt and Async decrypt

Parameters:
string
(Type: String)  The text to be decrypted.privateKey
(Type: String)  Private key in Base64 format.cipherAlgorithm
(Type: String)  The cipher algorithm used for encryption.

Function:
 Decrypts the input string with the provided private key using the specified cipher algorithm.
 Returns:
String
 Decrypted text.

Event:
 Event
Decrypted
 Raised after async decryption. data
(Type: String)  Decrypted data.
AsyncEncrypt and AsyncDecrypt
 Asynchronous Functions:
 Performs encryption and decryption asynchronously to avoid blocking the UI.
 Raises events
Encrypted
andDecrypted
with the result.
Digital Signatures
Sign and Async sign

Parameters:
string
(Type: String)  The text to be signed.privateKey
(Type: String)  Private key in Base64 format.hashAlgorithm
(Type: String)  The hashing algorithm to be used for signing.

Function:

Signs the input string with the provided private key using the specified hash algorithm.

Returns:
String
 Signature in Base64 format. 
Event:

Signed
 Raised after async signing.data
(Type: String)  Signature in Base64.
SignatureCheck and AsyncSignatureCheck

Parameters:
string
(Type: String)  The text that was signed.signature
(Type: String)  Signature in Base64 format.publicKey
(Type: String)  Public key in Base64 format.hashAlgorithm
(Type: String)  The hashing algorithm used for signing.

Functions:
SignatureCheck
 Checks if the signature is correct synchronously and returns a boolean.AsyncSignatureCheck
 Checks the signature asynchronously and raises theSignatureChecked
event with the result.

Event:
SignatureChecked
 Raised after async signature verification.data
(Type: boolean)  TRUE if the signature is correct, FALSE if incorrect.
Additional Properties
RSA Cipher algorithms for encrypting and decrypting
Cipher_PKCS1Padding
Supported in all Android versionsCipher_OAEPWithSha1
Support starting from Android API level 18 (Android 4.3, Jelly Bean MR2)Cipher_OAEPWithSha256
Support starting from Android API level 23 (Android 6.0, Marshmallow)Cipher_OAEPWithSha512
Support starting from Android API level 23 (Android 6.0, Marshmallow)
Hashing algorithms for signing
XtensionInfo
Property to get information about the extension (name, version, copyrights).
XtensionUUID
Property to get the extension UUID.
Example App blocks
Extension UUID
664650f9a36d48ad86313a4c3b217ddf
Copyrights & License

RSAcryptography Eric M. Kok (appsbeheerder)
RSA cryptography extension GPL v3 License
©2024 Eric M. Kok (appsbeheerder).
Based on AsymmetricCryptography : An extension for asymmetric cryptography ©2021 Sunny GuptaThis program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
Donating
A lot of work is put in this extension and the documentation. Support me for more work on extensions.
Donate me at https://paypal.me/ericdemagier
MIT Appathon use of extension
 You are allowed to use the .aix (jar) extension RSAcryptography, as part of an MIT Appathon app. https://appathon.appinventor.mit.edu/