RSA keygen, encryption and signatures
A pure TypeScript RSA implementation: generate a key pair of a chosen size from a deterministic seed (so results reproduce), parse PEM public/private keys, encrypt and decrypt with PKCS#1 v1.5 or OAEP, and sign or verify with the SHA family. Keys and plaintext stay local; this is a teaching and integration-test implementation — prefer an audited library for production.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Result
Everything is computed locally; keys and plaintext are never uploaded.
Enter content to see the result
Key bits: 0 · Input bytes: 0 · Output bytes: 0 · Operation index: 0
What this tool does
- Generate a reproducible demo key pair to exercise an encrypt/sign pipeline.
- Parse n / e / d out of a PEM to debug key formats.
- Compare PKCS#1 v1.5 and OAEP padding and check signature verification.
Example
Input
1024
Output
# bits=1024 e=65537 seed=7 (deterministic demo key) # modulus(n) hex: cd4459b55d15d98e60ec2a6d4f014d3aaae618ab5a8d6427cd595e6770f102b189f2ccdfcc6f92b8ebadc3562511830d0fffeae349fff891dcc4f125e37d05226f17f5aece90e8029d33b6bbe6c5a6744f296cecc8557cd62d74b2b9fab39fd81773f82b3a43137dd9cac1acff11de4f72867ed52fe8eae7632eb3c5db2b6c1f # compact public : rsa-pub:cd4459b55d15d98e60ec2a6d4f014d3aaae618ab5a8d6427cd595e6770f102b189f2ccdfcc6f92b8ebadc3562511830d0fffeae349fff891dcc4f125e37d05226f17f5aece90e8029d33b6bbe6c5a6744f296cecc8557cd62d74b2b9fab39fd81773f82b3a43137dd9cac1acff11de4f72867ed52fe8eae7632eb3c5db2b6c1f:010001 # compact private: rsa-priv:cd4459b55d15d98e60ec2a6d4f014d3aaae618ab5a8d6427cd595e6770f102b189f2ccdfcc6f92b8ebadc3562511830d0fffeae349fff891dcc4f125e37d05226f17f5aece90e8029d33b6bbe6c5a6744f296cecc8557cd62d74b2b9fab39fd81773f82b3a43137dd9cac1acff11de4f72867ed52fe8eae7632eb3c5db2b6c1f:010001:87bf550860f80b396295ac753f935fcc95aab7d3d27dc127a5611dd290d9826b810c463b170b0e6026d472632cfe88c981b4405571e1cb3443692705648d906f86c5b37ab5b4757c6b0e151ef3b48d1d153be37718cbced79c62bb544f02cb16ebee1864ff2a6efb5c381b30f09dbe48d571f24ec3765dcb39b819762457c9e9:db72149e8255d23baa4fc33d72b2860158ff4cacacd4a7c1b5f6a0cdf8c10263b31f184e6bcb7b874f50060f459bbb46ba8408886d3b81d7f7da7c1caa09ef33:ef75a4dc55fe5585bc783377f98fdd496800e7bf5d56dca1cfbddd0d1fc99944be2d6d8e79a3a681a5aec49c95eac9ae48a117ad54603a0a31daf9fcf913bf65 -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDNRFm1XRXZjmDsKm1PAU06quYY q1qNZCfNWV5ncPECsYnyzN/Mb5K4663DViURgw0P/+rjSf/4kdzE8SXjfQUibxf1 rs6Q6AKdM7a75sWmdE8pbOzIVXzWLXSyufqzn9gXc/grOkMTfdnKwaz/Ed5PcoZ+ 1S/o6udjLrPF2ytsHwIDAQAB -----END PUBLIC KEY----- -----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQDNRFm1XRXZjmDsKm1PAU06quYYq1qNZCfNWV5ncPECsYnyzN/M b5K4663DViURgw0P/+rjSf/4kdzE8SXjfQUibxf1rs6Q6AKdM7a75sWmdE8pbOzI VXzWLXSyufqzn9gXc/grOkMTfdnKwaz/Ed5PcoZ+1S/o6udjLrPF2ytsHwIDAQAB AoGBAIe/VQhg+As5YpWsdT+TX8yVqrfT0n3BJ6VhHdKQ2YJrgQxGOxcLDmAm1HJj LP6IyYG0QFVx4cs0Q2knBWSNkG+GxbN6tbR1fGsOFR7ztI0dFTvjdxjLztecYrtU TwLLFuvuGGT/Km77XDgbMPCdvkjVcfJOw3Zdyzm4GXYkV8npAkEA23IUnoJV0juq T8M9crKGAVj/TKys1KfBtfagzfjBAmOzHxhOa8t7h09QBg9Fm7tGuoQIiG07gdf3 2nwcqgnvMwJBAO91pNxV/lWFvHgzd/mP3UloAOe/XVbcoc+93Q0fyZlEvi1tjnmj poGlrsSclerJrkihF61UYDoKMdr5/PkTv2UCQQCI++efIuELwS8JZ2jeRk6cXL/R TyD8BlRHkFLFAHkLUs0npfaeF4Fe78WWYsYi9n6qQ21ILFevL++KNVt3UYg9AkBf XUbOySCFBsHMTRMWvIiwV08k/D07/poilcaXF3W+KHZkuSDoqJgDQeycOJAr9S4H lsBLMzMvaif4wV5SA99RAkAXpsJ+1LWjzZ0SK/lbtua6Di0vbz4GQ5mSN7dB+9s6 p+Kex8gssoaEdSqOTHd7nVQkGP5Saf0eJDfsXK/P2lyZ -----END RSA PRIVATE KEY-----
With a fixed seed (seed=7) key generation is reproducible: the modulus n in hex is identical on every run, which makes it usable as a test vector.
Frequently asked questions
Can I use the generated key in production?
Not recommended. This is a pure TypeScript teaching implementation whose randomness comes from a deterministic seed (for reproducibility) and which has no side-channel hardening; generate keys with OpenSSL or an audited library instead.
Which paddings are supported?
PKCS#1 v1.5 (RSAES-PKCS1-v1_5 / EMSA-PKCS1-v1_5) and OAEP (RFC 8017 §7.1 with MGF1). AEADs such as GCM are unrelated to RSA and out of scope.
What happens with long text?
RSA can only encrypt (modulus length − padding overhead) bytes per operation — 117 bytes for a 1024-bit key with PKCS#1 v1.5 and 62 bytes with OAEP-SHA256. This tool chunks automatically and concatenates, so long input never fails; the ciphertext is simply a multiple of the block size (128 bytes for 1024 bits). It is refused only when the key is too small for even one block, such as 512 bits with OAEP-SHA512.
What is the difference between signing and encrypting?
Signing uses the private key and verification the public key, proving origin and integrity; encryption uses the public key and decryption the private key, providing confidentiality. They are not interchangeable.
Keywords:RSAOAEPPKCS#1RSA keygen