RC4A.js v0.1.2
NodeJS/JavaScript implementation of simple and powerfull string encryption/decryption with the password & UTF-8 support. You can encrypt string in the browser and decrypt it on the PHP-server. Or encrypt on the PHP-server and decrypt in browser.
Go to RC4A for PHP on GitHub
No dependecies! No OpenSSL required. Javascript, NodeJS, PHP compatible.
How to use in project
JavaScript:
NodeJS:
var rc4a = ;
Encryption
var text = "Lorem ipsum 123 ёюйяъэ !№;%:?*()";var password = "supёrP@$$w0rd";var secret = rc4a;console; // Will output something like this: ]êòd»÷[c #hümZºí¤xì/S-ѲѩҴӷдӂp±⅁ÑD_»¼ú{
Decryption
var decryptedText = rc4a;console; // Will output: Lorem ipsum 123 ёюйяъэ !№;%:?*()
Encryption with the custom salt
RC4A.js automatically generate random salt via Math.random(). Salt size is dynamic - from 16 up to 128. If you do not trust, you can use your own salt up to 9999-size length. Just specify it:
var customSalt = "397ba6e0085f182db7ee7f6e3515530d";var secret = rc4a;
And that's it. You don't have to pass salt for the decryption.
Error catching
Do not forget about damaged data. Test your code like this:
var text = "Lorem ipsum 123 ёюйяъэ !№;%:?*()";var password = "supёrP@$$w0rd";var secret = rc4a; // let's damage this encrypted contenttry var decryptedText = rc4a; // here you will get an error console;catche console;
TODO:
- Beatiful Threw Error
- Add streams