Skip to content

Instantly share code, notes, and snippets.

View rilleralle's full-sized avatar

Ralf Strobel rilleralle

View GitHub Profile
@joecliff
joecliff / cryptojs_base64_encrypt_decrypt.js
Last active October 10, 2024 19:44
An example of base64 usage in cryptojs
var CryptoJS = require("crypto-js");//replace thie with script tag in browser env
//encrypt
var rawStr = "hello world!";
var wordArray = CryptoJS.enc.Utf8.parse(rawStr);
var base64 = CryptoJS.enc.Base64.stringify(wordArray);
console.log('encrypted:', base64);
//decrypt
var parsedWordArray = CryptoJS.enc.Base64.parse(base64);