Text encryption and random tokens

Password-based encryption

Both methods accept a nonempty string and a password of at least four characters. Use the encrypted string returned by encryptText as input to decryptText:

sdk.encryptText('Hello', 'your-password', onSuccess, onError);
sdk.decryptText(encryptedText, 'your-password', onSuccess, onError);

encryptedText is the previous encryption result. The quick start above shows the full round trip. These methods do not require a Geens login.

RSA encryption and decryption

RSA methods require a logged-in user's stored credentials. Pass a public key to encrypt for a specific recipient, or null to use the current user's key. The SDK still requires local user data when an explicit public key is provided. Decrypt with the corresponding user's stored private key:

sdk.rsaEncryptText('Hello', null, onSuccess, onError);
sdk.rsaDecryptText(rsaEncryptedText, onSuccess, onError);

rsaEncryptedText is a result from rsaEncryptText; RSA supports short payloads, not arbitrary file content.

Generate a random token

Generates a 32-character token. The first argument excludes individual characters; true limits the result to letters and numbers. Ensure the exclusions leave an available alphabet.

sdk.generateCryptographicallySafeRandomToken([], true, onSuccess, onError);