An RSA key generator on Android can create a 2048- or 3072-bit RSA-OAEP key pair with SHA-256 in a browser, with the public key exported as SPKI PEM and the private key as unencrypted PKCS#8 PEM.

This RSA Key Generator uses the browser's native Web Cryptography implementation, so the Android workflow is browser-based rather than an APK or Android signing utility. It is intended for applications that exchange RSA-OAEP encryption keys using standard PEM files.

rsa key generator on android
RSA Key Generator on Android: Browser Workflow

What the Android browser workflow produces

RSA uses a public key to encrypt material and a mathematically related private key to decrypt it. The generated pair is designed for RSA-OAEP with SHA-256, a public exponent of 65537, and a selectable modulus length of 2048 or 3072 bits.

Output Envelope Purpose on Android Distribution rule
Public key SPKI PEM beginning with BEGIN PUBLIC KEY Encrypt a compatible message or wrapping key for the private-key holder May be given to the application or other system that needs to encrypt for you
Private key Unencrypted PKCS#8 PEM beginning with BEGIN PRIVATE KEY Decrypt material encrypted with the matching public key Move directly into protected storage and do not distribute it

The PEM text is a Base64 representation of the key structures, following the format defined by RFC 7468. A successful import is only the first compatibility check. The consuming application must also use matching RSA-OAEP parameters, including SHA-256 and the required label and mask-generation settings.

Choose the key size

Both available sizes use the same fixed RSA-OAEP configuration and public exponent. Select the size according to what the receiving application supports rather than choosing only by generation speed.

Option Compatibility Security and performance
2048 bits Broadly interoperable Lower browser and cryptographic cost
3072 bits Supported by the generator when the application accepts it Provides a larger security margin, with slower generation and operations

Generation is asynchronous, so allow the selected operation to finish before copying either result. Secure key generation is random: running the generator twice with identical settings is expected to produce different key pairs, so there is no correct fixed private-key value to compare against.

Generate the key pair on Android

  1. On a trusted, patched Android device, open a browser that supports the page's Web Crypto operation and visit the RSA Key Generator. The tool generates and exports keys in the current tab; no key bytes are sent to the application server.

  2. Confirm that the application or counterpart explicitly requires RSA-OAEP with SHA-256, exponent 65537, and SPKI public-key and PKCS#8 private-key PEM. If it expects RSA signatures, an X.509 certificate, an SSH key, PKCS#1 v1.5 encryption, SHA-1, or another envelope, do not use this output.

  3. Choose 2048 or 3072 bits. Select 2048 bits when broad interoperability is the priority. Choose 3072 bits only when the application supports that modulus length and you accept the additional generation and operation cost.

  4. Start generation and wait for it to complete. When the job finishes, identify the public output by its BEGIN PUBLIC KEY header and the private output by its BEGIN PRIVATE KEY header. Use only the pair produced by the completed job.

  5. Copy the public SPKI PEM and send it only to the system that needs to encrypt for the holder of the private key. If the Android application performs encryption, configure it with this public key. If it performs decryption, retain the corresponding private key for import.

  6. Copy the private PKCS#8 PEM and import it directly into an appropriate protected keystore or secret manager that your application supports. The PEM is not password-encrypted, so a saved text file, source repository, chat message, ticket, analytics record, ordinary note, or browser-synced file is not adequate protection.

  7. Run an end-to-end test through the real application protocol. Encrypt a short, known UTF-8 message with the public key, decrypt it with the imported private key, and confirm that the recovered text matches exactly.

  8. After the private key is safely imported, clear the clipboard history and close the generator tab. The generated outputs otherwise remain in component memory until the page is navigated away from or the pair is replaced, but extensions, malware, clipboard managers, and screenshots remain outside that boundary.

Protect the private key during handoff

The most important Android-specific concern is the interval between copying the private PEM and securing it. Anyone who obtains the unencrypted private key can decrypt compatible ciphertext. Copying it transfers full responsibility for its protection, so avoid leaving it on the clipboard longer than necessary.

Use a protected secret manager or encrypted keystore with strict access controls and appropriate backups. Do not paste the private key into a messaging app, attach it to an issue, place it in source control, or include it in logs. If it may have been viewed, synchronized, captured, or exposed, rotate it immediately by generating a new pair and updating the systems that depend on it.

Keeping the generator in component memory does not make the surrounding device inherently trusted. Browser extensions and malware can observe data outside the page's control, and clipboard or screenshot tools can capture copied PEM text. A trusted, patched device and a direct import into protected storage are therefore part of the workflow, not optional extras.

Verify the application protocol

The key files declare SHA-256, but another system may default to SHA-1 or use different RSA-OAEP label and mask-generation settings. Those defaults can prevent successful decryption even when both PEM files import correctly. The RSA-OAEP requirements are defined in RFC 8017, while the surrounding application protocol determines the settings that must match.

Check that the imported private key reports the selected modulus length and algorithm. Then test the complete direction that matters to the application: public-key encryption followed by private-key decryption for data sent to you, or the reverse path if you are publishing material that another party must decrypt.

The recovered plaintext must match exactly, not merely appear readable. A protocol-level round trip catches problems that a PEM parser cannot, including mismatched OAEP settings and an incorrectly configured application interface. If the application cannot import the browser-generated private key or demands a different security boundary, use the key-generation workflow provided by the owning Android platform or a hardware security module instead.

Encrypt data correctly with RSA-OAEP

RSA can encrypt only a limited amount of data directly. It is not a method for splitting a large file into raw RSA blocks. A typical application protocol generates a random symmetric key, protects that key with RSA-OAEP, and uses authenticated symmetric encryption for the actual file or message.

This generator intentionally produces keys only; it does not create a hybrid file container or define an application-specific payload format. Follow the recipient's protocol for key wrapping, metadata, encoding, and authenticated encryption rather than inventing a format around the generated PEM files.

Know what this tool does not create

The output is an RSA-OAEP encryption key pair, not an Android application signing key or keystore. The utility does not create X.509 certificates, certificate signing requests, RSA-PSS signatures, SSH keys, JSON Web Keys, raw RSA keys, or PKCS#1 v1.5 encryption keys. It also does not offer 1024-bit keys, custom public exponents, or SHA-1 configurations.

For production identity, code signing, or TLS, prefer the key-generation workflow provided by the owning platform or a hardware security module. Use this browser workflow when the exact requirement is an importable RSA-OAEP encryption key with SHA-256, exponent 65537, and SPKI/PKCS#8 PEM.