Simple Free RSA / AES Encryption and Decryption
Open and free for all to see, can be run stand-alone on a local machine for an extra sense of security; all functionality runs entirely locally once the page has been loaded. Latest client version be loaded directly from the GitHub repo here.
If you've found this tool useful, please consider making a donation!
RSA encryption operates on a very limited string length, it is generally used to asymmetrically encrypt a shared secret that in turn is used for symmetric encryption. The standard use-case is to generate a random shared secret and transmit it encrypted with the destination's public RSA key. Once the destination has decrypted the shared secret with its private RSA key both sides will be able to use that secret to encrypt and decrypt communication with AES.
Signing a message to prove authorship (and that it hasn't been tampered with) is performed on the plaintext message, and the resulting signature can only be verified with the public key matching the private key it was signed with. The padding for signing and verifying signatures is not the same as for encrypting and decrypting messages.
The AES secret must be a 32 character string. In order to ensure a valid string, the provided secret is always hashed using the MD5 algorithm to produce a string of the correct length.
The IV, or Initialization Vector, is a 16 character hexadecimal string that's required by the AES algorithm (read this for a detailed explanation). It's not really necessary when encryption secrets aren't being reused, but as it's enforced by the underlying crypto package it's recommended to include it. If you do choose to leave it out, a default IV of '0000000000000000' will be used.
Signing messages and verifying signatures with simple-free-encryption-tool are performed using the SHA-256 hashing algorithm.
npm install simple-free-encryption-tool
Testing and Building
npm testnpm run build
const sfet = ;console;console;console;// (key size defaults to 2048 if null)let keySize = 2048;// generateKeys() runs key generation in a separate child processsfetrsa;let keys = sfetrsa;console;let encrypted = sfetrsa;let decrypted = sfetrsa;console;// signing an rsa messagelet signature = sfetrsa;console;// verifying an rsa signatureconsole// using default iv of '0000000000000000'encrypted = sfetaesdecrypted = sfetaes;console;// using generated iviv = sfetaes;encrypted = sfetaesdecrypted = sfetaes;console;
C# counterparts available in the
/examples/csharp folder as well as on gist:
- RSA key importer / exporter: https://gist.github.com/therightstuff/aa65356e95f8d0aae888e9f61aa29414
- RSA encrypt / decrypt / sign / verify: https://gist.github.com/therightstuff/4db89368887dba2fe8935b2fb329f5aa
- AES encrypt / decrypt: https://gist.github.com/therightstuff/30e5cbd9b1e0de1b8865c8fb6e2971e4