I would like to know if it is possible to encrypt and decrypt a text, using pure JavaScript. I don't want to use a key. It may be an entry lever solution. But I simply want to encode a text "my-name-1" into some text format and want to retrieve the text from it. Is this possible, without using any js libraries?
Without a key (or some secret for that matter), you wont get any kind of encryption.
What you mean is something like a different encoding. So maybe Base64 is something for you.
var baseString = 'my-name-1';
var encodedString = window.btoa( baseString ); // returns "bXktbmFtZS0x"
var decodedString = window.atob( encodedString ); // returns "my-name-1"
This is supported in all major browsers. IE support just in IE10+.
References:
window.btoa()
window.atob()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With