forked from wangyiwy/oktools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash.html
92 lines (90 loc) · 3.47 KB
/
hash.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html lang="zh_CN">
<head>
<meta charset="UTF-8">
<title>Hash计算 MD5、SHA1、SHA224、SHA-256、SHA384、SHA512计算 - 在线工具 - OKTools</title>
<meta name="keywords" content="Hash计算,MD5计算,SHA1计算,SHA-256计算,SHA512计算,哈希">
<meta name="description" content="在线Hash计算工具,MD5计算,SHA1计算,SHA-256计算,SHA512计算,哈希">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" href="/static/css/style.css" type="text/css">
</head>
<body>
{{template "aside"}}
<main>
<div class="container">
<h1>Hash计算</h1>
<textarea id="area_text" class="textarea mt-2" rows="15" placeholder="字符串"></textarea>
<div class="group fullwidth mt-2">
<select id="select_algo" class="select" onchange="calHash()">
<option value="MD5">MD5</option>
<option value="SHA1">SHA1</option>
<option value="SHA224">SHA224</option>
<option value="SHA256">SHA256</option>
<option value="SHA384">SHA384</option>
<option value="SHA512">SHA512</option>
<option value="Hmac-MD5">Hmac-MD5</option>
<option value="Hmac-SHA1">Hmac-SHA1</option>
<option value="Hmac-SHA224">Hmac-SHA224</option>
<option value="Hmac-SHA256">Hmac-SHA256</option>
<option value="Hmac-SHA384">Hmac-SHA384</option>
<option value="Hmac-SHA512">Hmac-SHA512</option>
</select>
<input id="input_key" class="input" placeholder="密钥,非必填">
<button class="button primary" onclick="calHash()">计算</button>
</div>
<input id="input_hash" class="input mt-2" rows="1" placeholder="Hash值"/>
</div>
</main>
<script src="https://cdn.bootcss.com/crypto-js/3.1.9-1/crypto-js.min.js"></script>
<script>
function calHash() {
let text = document.getElementById('area_text').value;
if (!text) {
return
}
let key = document.getElementById('input_key').value;
let algo = document.getElementById('select_algo').value;
let hash;
switch (algo) {
case 'MD5':
hash = CryptoJS.MD5(text);
break;
case 'SHA1':
hash = CryptoJS.SHA1(text);
break;
case 'SHA224':
hash = CryptoJS.SHA224(text);
break;
case 'SHA256':
hash = CryptoJS.SHA256(text);
break;
case 'SHA384':
hash = CryptoJS.SHA384(text);
break;
case 'SHA512':
hash = CryptoJS.SHA512(text);
break;
case 'Hmac-MD5':
hash = CryptoJS.HmacMD5(text, key);
break;
case 'Hmac-SHA1':
hash = CryptoJS.HmacSHA1(text, key);
break;
case 'Hmac-SHA224':
hash = CryptoJS.HmacSHA224(text, key);
break;
case 'Hmac-SHA256':
hash = CryptoJS.HmacSHA256(text, key);
break;
case 'Hmac-SHA384':
hash = CryptoJS.HmacSHA384(text, key);
break;
case 'Hmac-SHA512':
hash = CryptoJS.HmacSHA512(text, key);
break;
}
document.getElementById('input_hash').value = hash;
}
</script>
</body>
</html>