Astroport.ONE/www/AESBox/index.html

61 lines
1.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>CryptoJS Decryption</title>
<script type="module">
import * as openpgp from './openpgp.min.mjs';
</script>
</head>
<body>
<h1>CryptoJS Decryption</h1>
<p>Please enter the password to decrypt the hidden value:</p>
<input type="password" id="password" />
<input type="hidden" id="secretssl" value="jA0ECQMC9HPdy3G2HU7+0lgBuXAZSHSZTtwnq3Ygl48Z8fIgblnTBRNUYvtavTPFBEsAUUI+M/GddxMaXxreaKSo/aaAB+bvcoe8pn4Ivqf0SwHGmNMErXFZ2EY14OUMX6dV8vOOl4Fy"/>
<div id="decrypted">Please wait...</div>
Insert new note:<input type="text" id="new_note"><input type="button" id="enc_button" value="Encrypt & Decrypt">
<script type="text/javascript">
function _base64ToArrayBuffer(base64) {
var binary_string = window.atob(base64);
var len = binary_string.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes.buffer;
}
document.getElementById("enc_button").onclick = function(){
(async () => {
var base64Value = document.getElementById("secretssl").value;
var encrypted = _base64ToArrayBuffer(base64Value);
alert(encrypted)
const encryptedMessage = await openpgp.readMessage({
binaryMessage: encrypted // parse encrypted bytes
});
const { data: decrypted } = await openpgp.decrypt({
message: encryptedMessage,
passwords: ['123456'], // decrypt with password
format: 'binary' // output as Uint8Array
});
console.log(decrypted); // Uint8Array([0x01, 0x01, 0x01])
})();
}
</script>
</body>
</html>