|
@@ -3,18 +3,45 @@
|
|
|
<head>
|
|
|
<meta charset="utf-8" />
|
|
|
<title>Chacha20</title>
|
|
|
<style type="text/css">
|
|
|
textarea{width:400px;height:160px;}
|
|
|
form[name="chacha"] > *, form[name="chacha"] label > * {display:block;margin-bottom:8px;}
|
|
|
</style>
|
|
|
<script type="text/javascript" src="main.js"></script>
|
|
|
</head>
|
|
|
<body>
|
|
|
<form name="chacha">
|
|
|
<textarea name="input"></textarea>
|
|
|
<input type="password" name="password" />
|
|
|
<button type="button" name="encrypt">zašifrovat</button>
|
|
|
<button type="button" name="decrypt">dešifrovat</button>
|
|
|
<textarea name="output"></textarea>
|
|
|
<label>Vstup:
|
|
|
<textarea name="input"></textarea>
|
|
|
</label>
|
|
|
<label>Heslo:
|
|
|
<input type="password" name="password" />
|
|
|
</label>
|
|
|
<div>
|
|
|
<button type="button" name="encrypt">zašifrovat</button>
|
|
|
<button type="button" name="decrypt">dešifrovat</button>
|
|
|
</div>
|
|
|
<label>Výstup:
|
|
|
<textarea name="output" readonly></textarea>
|
|
|
</label>
|
|
|
</form>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
let form=document.querySelector("form[name='chacha']");
|
|
|
let input=form.querySelector("textarea[name='input']");
|
|
|
let output=form.querySelector("textarea[name='output']");
|
|
|
let password=form.querySelector("input[name='password']");
|
|
|
|
|
|
form.querySelector("button[name='encrypt']").addEventListener("click",function(){
|
|
|
output.value=cryptoJS.encrypt(input.value,password.value);
|
|
|
});
|
|
|
|
|
|
form.querySelector("button[name='decrypt']").addEventListener("click",function(){
|
|
|
let res=cryptoJS.decrypt(input.value,password.value);
|
|
|
if(res===1){res="! Nepodařilo se ověřit pravost zprávy. !";}
|
|
|
else if(res===2){res="! Nekompatibilní verze programu. !";}
|
|
|
output.value=res;
|
|
|
});
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|