Created
November 13, 2013 22:57
-
-
Save ivanoats/7458034 to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Message Decoder</h1> | |
<button id="decrypt">Decrypt!</button> | |
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script> | |
<script> | |
var decoder = { | |
getPassword: function() { | |
this.password = prompt("Enter your password") | |
}, | |
getCypherText: function() { | |
this.cypherText = document.URL.split('?')[1] | |
}, | |
decrypt: function() { | |
this.getPassword() | |
this.getCypherText() | |
alert(CryptoJS.AES.decrypt(this.cypherText, this.password).toString(CryptoJS.enc.Utf8)) | |
}, | |
} | |
document.getElementById('decrypt').onclick = function() { decoder.decrypt() } | |
</script> | |
</body> | |
</html> |
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
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Message Encoder</h1> | |
<p>This simple page lets you securely encrypt a message with a password. Your message will not leave your computer, and will not be sent over the Internet.</p> | |
<p>Once it's encoded, you'll be able to share your message with anyone else who has the password.</p> | |
<textarea id="message" rows="6" cols="60"></textarea> | |
<br> | |
<button id="encrypt" onclick="encoder.protect()">Lock Down</button> | |
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script> | |
<script> | |
var encoder = { | |
setMessage: function() { | |
this.message = document.getElementById('message').value | |
}, | |
getPassword: function() { | |
this.password = prompt("Enter your password") | |
}, | |
setUrl: function() { | |
this.url = document.URL + "decode.html?" + this.encrypt() | |
}, | |
replaceMessageWithUrl: function () { | |
document.getElementById('message').value = this.url | |
}, | |
encrypt: function() { | |
cypher = CryptoJS.AES.encrypt(this.message, this.password) | |
console.log("Verified: " + | |
CryptoJS.AES.decrypt(cypher, this.password).toString(CryptoJS.enc.Utf8)) | |
return cypher | |
}, | |
protect: function() { | |
console.log("protecting!"); | |
this.setMessage() | |
this.getPassword() | |
this.setUrl() | |
this.replaceMessageWithUrl() | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment