A Simple Script That Quickly Encrypts Text Into An Unreadable Incoherent String Of Chars And Back Again.
crypt, Despite its Name, Is Not Secure. It Is Not To Be Used In Any Place Where Any Form Of Sensitive Data Is Being Transferred Or Stored. It Is Easy To Break And Can Be Broken Quickly Using A Simple Brute-Force Attack.
First Download And Store The File crypt.min.js Somewhere. (Such As Near Your HTML Files Or As In A Folder Called Scripts.)
(This Is The Minified Version And Won't Be Easily Readable, To Understand How It Works Download crypt.js And Open It Up In Your Text Editor Of Choice To Take A Look.)
This Part Is Optional. Yep It Doesn't Even Need To Be In A Page, But If You Want To Use It In A Web App Just Copy The Snippet Below Into your HTML File's Head And Replace {{foo}} With The Path To Where You Downloaded crypt.js.
<script src="{{foo}}"></script>
To Use It Without A Full Fledged App, Such As For A Single String, Copy The Contents Of crypt.min.js Into Chrome Devtools' Console (Press F12
Or CTRL\CMD + Shift + i
On Your Keyboard While On Any Page On Chrome Then Open The Console Tab)
(Works Best In Chrome Devtools Compared to Other Browsers' Consoles)
Using It In Your Code Is Also Very Simple. Replace {{foo}} With What You Want To Encrypt/Decrypt And {{bar}} With The Key To Use In The Snippet Below.
crypt("{{foo}}","{{bar}}");
The Key Can Be Anything But A Long Key Is Usually Better.
The Function Will Return A String Of The Same Length But The String May Or May Not Be Viewable, Depending On Your Charset. To Transfer The String Without It Becoming Damaged You Should Encode It.
This Tiny Snippet Of Code Is Licensed Under The MIT License. This Is A Short And Simple Permissive License Which Only Requires Preservation Of Copyright And License Notices. Basically, In Your Code Write A Little Comment Stating That I Made This Snippet Of Code. Take A Look At The License For The Exact Conditions