Skip to content

Instantly share code, notes, and snippets.

@clochix
Created July 16, 2014 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clochix/9dc78cf25c6805c0b757 to your computer and use it in GitHub Desktop.
Save clochix/9dc78cf25c6805c0b757 to your computer and use it in GitHub Desktop.
Encode and decode mails
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chiffre</title>
<link rel="icon" type="image/png" href="" />
<style type="text/css">
html, body {
height: 100%;
width: 100%;
}
#tab {
list-style-type: none;
}
#tab > li {
display: inline;
}
</style>
</head>
<body>
<p><label>Mot de passe : <input type="text" id="password"></input></label></p>
<p><textarea id="text" rows="24" cols="80"></textarea></p>
<p>
<input type="button" id="decrypt" value="Déchiffrer"/>
<input type="button" id="encrypt" value="Chiffrer"/>
</p>
<p id="result"></p>
<script src="aes.js"></script>
<script type="text/javascript">
var dec = document.getElementById('decrypt'),
enc = document.getElementById('encrypt'),
pass = document.getElementById('password'),
text = document.getElementById('text'),
result = document.getElementById('result');
dec.addEventListener('click', function onClick() {
result.innerHTML = CryptoJS.AES.decrypt(text.value, pass.value).toString(CryptoJS.enc.Utf8).replace(/\n/gm, '<br />');
});
enc.addEventListener('click', function onClick() {
var crypted = CryptoJS.AES.encrypt(text.value, pass.value).toString().replace(/\n/gm, '<br />');
result.innerHTML = "Pour lire ce message, copiez son contenu dans le formulaire sur http://clochix.net/crypt/#" + crypted + "<br />";
result.innerHTML += "Mot de passe : " + pass.value + "<br \><br \>";
result.innerHTML += "Message :<br \><br \>"+ crypted;
});
if (window.location.hash !== "") {
text.value = window.location.hash.substr(1);
}
</script>
</body>
</html>
#!/bin/bash
INPUT=$(cat /dev/stdin)
export PASS=`openssl rand -base64 6`
TXT=`printf "%s\n" "$INPUT" | openssl enc -aes-256-cbc -pass env:PASS -e -base64 -A`
echo -e "Pour lire ce message, copiez son contenu dans le formulaire sur http://clochix.net/crypt/#$TXT";
echo -e "Mot de passe : $PASS\n\nMessage :\n\n$TXT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment