-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsha256.html
37 lines (35 loc) · 1.18 KB
/
sha256.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Sha256</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/forge/0.8.2/forge.all.min.js"></script>
<style>
.center{
border:5px solid #FFFF00;
text-align:center;
}
</style>
<script type="text/Javascript">
function generateHash()
{
var plainText = document.getElementById('plainText').value;
var md = forge.md.sha256.create();
md.start();
md.update(plainText, "utf8");
var hashedT = md.digest().toHex();
document.getElementById("hashedT").innerHTML = hashedT;
}
</script>
</head>
<body>
<div class="center">
<h1> JS SHA256 Hash Example using Forge</h1>
<br> <br> <strong> Enter the sample text: </strong><input id='plainText' type='text'/>
<br> <br> <strong> Hashed Text (SHA 256): </strong><span id='hashedT'></span>
<br> <br> <button onclick="generateHash()"> Generate Hash </button>
</body>
</html>