<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Cryptography in JavaScript</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="ext.js"></script>
<script type="text/javascript" src="md5.js"></script>
<script type="text/javascript" src="bits.js"></script>
<script type="text/javascript" src="gf28.js"></script>
<script type="text/javascript" src="aes.js"></script>
<script type="text/javascript">
function $(id)
{
return document.getElementById(id)
}
function tohexarray(str)
{
var s = '0123456789abcdef'
var ht = {}
for (var i = 0; i < 16; i++)
ht[s[i]] = i
var a = str.split(' ')
for (var i in a)
a[i] = 16 * ht[a[i][0]] + ht[a[i][1]]
return a
}
</script>
<style type="text/css">
body { font-family:calibri }
h1 { border-top: 1px solid lightblue; color:darkblue }
div.footnote { color:lightgray; position:absolute; right:1em; bottom:1em }
</style>
<body>
<h1>Encrypting</h1>
<script type="text/javascript">
var ed = {}
ed.encrypt = function()
{
$('cipherinfo').innerHTML = ' '
var text = $('plaintext').value.bytes('ascii')
var pass = $('password').value.bytes('ascii')
var ciph = aes.encrypt(text, pass)
$('cipher').value = bits.hex(ciph, 1)
}
ed.decrypt = function()
{
var ciph = tohexarray($('cipher').value)
var pass = $('password').value.bytes('ascii')
var text = aes.decrypt(ciph, pass)
var s = ''.frombytes(text)
$('cipher').value = s
$('cipherinfo').innerHTML = s == $('plaintext').value ?
'The result matches the plaintext'.bold().fontcolor('green') :
'The result mismatches the plaintext'.bold().fontcolor('red')
}
</script>
<table>
<tr><td>
<textarea cols="60" rows="10" id="plaintext">
In cryptography, the Advanced Encryption Standard (AES) is a symmetric-key encryption standard adopted by the U.S. government. The standard comprises three block ciphers, AES-128, AES-192 and AES-256, adopted from a larger collection originally published as Rijndael. Each of these ciphers has a 128-bit block size, with key sizes of 128, 192 and 256 bits, respectively. The AES ciphers have been analyzed extensively and are now used worldwide, as was the case with its predecessor, the Data Encryption Standard (DES).
</textarea>
<tr><td id="cipherinfo">
<tr><td>
<select id="cipheralg">
<option>AES-128</option>
</select>
<input size="40" id="password" value="qwerty"></input>
<input type="button" value="Encrypt" onclick="ed.encrypt()"></input>
<input type="button" value="Decrypt" onclick="ed.decrypt()"></input>
<tr><td>
<textarea cols="60" rows="10" id="cipher"></textarea>
</table>
<div class="footnote">AES implementation for Habrahabr</div>
</body>
</html>
aes.zip_AES_DEMO_aes javascript_elaes_javascript aes
版权申诉
84 浏览量
2022-09-22
22:13:56
上传
评论
收藏 6KB ZIP 举报
weixin_42651887
- 粉丝: 81
- 资源: 1万+
最新资源
- 【贝叶斯算法】该文件是一个用于实现贝叶斯算法的 Python 脚本 贝叶斯算法基于贝叶斯定理,用于分类和预测问题
- 3个小项目分别是利用 Python 实现报表自动化、某连锁超市、某银行数据分析,展示了问题分解、数据清洗、数据分析与可视化的过程
- 基于Java图书管理系统毕设(源码+使用文档)
- COLMAP3.9版本下载资源包
- Python和R语言应用案例,提供1年的图书馆借阅数据,并进行大数据分析
- 基于Java局域网监听软件毕设(源码+使用文档)
- 遗传算法学习笔记 -DEAP库学习笔记
- MNIST手写数字识别数据集
- Python大作业相关文档2024.rar
- 医学图像分割数据:完整脊柱切片分割【包含3个切面划分的数据集(26类别)、标签文件、可视化代码】
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈