-
-
Save ohio813/5f77ee2e7263baa099868dc536f19a4f to your computer and use it in GitHub Desktop.
A JavaScript encryption/decryption bookmarklet based on https://qiita.com/useiichi/items/0786199ee61443df3af5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:w=window.open('','Links','scrollbars,resizable,width=640,height=550');w.document.write('<!DOCTYPE%20html><html><head><meta%20charset="utf-8"/><script%20src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/core.js"></script><script%20src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/sha1.js"></script><script%20src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/hmac.js"></script><script%20src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/enc-base64.js"></script><script%20src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/cipher-core.js"></script><script%20src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/aes.js"></script><script%20src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/pbkdf2.js"></script><script%20type="text/javascript">function%20encrypt(){var%20encypt_text=document.getElementById("encypt-text").value;var%20pass=CryptoJS.enc.Utf8.parse(document.getElementById("encrypt-password").value);var%20salt=CryptoJS.lib.WordArray.random(128/8);var%20key=CryptoJS.PBKDF2(pass,salt,{keySize:256/32,iterations:100});var%20iv=CryptoJS.lib.WordArray.random(128/8);var%20options={iv:iv,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7};var%20encrypted=CryptoJS.AES.encrypt(encypt_text,key,options);document.getElementById("transitmessage").value=salt.toString()+iv.toString()+encrypted.toString();}function%20decrypt(){document.getElementById("decrypted").value="";var%20transitmessage=document.getElementById("transitmessage").value;var%20salt=CryptoJS.enc.Hex.parse(transitmessage.substr(0,32));var%20iv=CryptoJS.enc.Hex.parse(transitmessage.substr(32,32));var%20encrypted=transitmessage.substring(64);var%20pass=CryptoJS.enc.Utf8.parse(document.getElementById("decrypt-password").value);var%20key=CryptoJS.PBKDF2(pass,salt,{keySize:256/32,iterations:100});var%20options={iv:iv,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7};var%20decrypted=CryptoJS.AES.decrypt(encrypted,key,options);document.getElementById("decrypted").value=decrypted.toString(CryptoJS.enc.Utf8);}</script></head><body><label%20for="encypt-text">Text%20to%20Encrypt:</label><br%20/><textarea%20id="encypt-text"%20rows="8"%20cols="85"></textarea><br%20/> ↓ <label%20for="encrypt-password">Password:</label><br%20/> ↓ <input%20id="encrypt-password"%20type="text"%20size="80"%20value=""%20/><br%20/> ↓ <input%20id="encrypt"%20type="button"%20value="Encrypt"%20onclick="encrypt()"%20/><br%20/><label%20for="transitmessage">Text%20to%20Decrypt:</label><br%20/><textarea%20id="transitmessage"%20rows="4"%20cols="85"></textarea><br%20/> ↓ <label%20for="decrypt-password">Password:</label><br%20/> ↓ <input%20id="decrypt-password"%20type="text"%20size="80"%20value=""%20/><br%20/> ↓ <input%20id="decrypt"%20type="button"%20value="Decrypt"%20onclick="decrypt()"%20/><br%20/><label%20for="decrypted">Decrypted%20Text:</label><br%20/><textarea%20id="decrypted"%20rows="8"%20cols="85"></textarea></body></html>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
comment pasted from original gist:
You can find out more about this here: https://steemit.com/privacy/@lukestokes/what-would-controlling-your-own-data-actually-look-like-on-steem
Also, note this bookmarklet will not work on some sites (such as Facebook). It will throw errors like this in the console log: