-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
87 lines (84 loc) · 2.58 KB
/
example.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
<html>
<meta http-equiv="Content-Type" content="text/html;charset=windows-1252" >
<head>
<script src="isaac.js" type="text/javascript"></script>
<script src="bCrypt.js" type="text/javascript"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://code.jquery.com/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
var id;
var bcrypt = new bCrypt();
function enable(){
if(bcrypt.ready()){
$("#submit").removeAttr("disabled");
$("#submit").attr("value","Generate Hash");
clearInterval(id);
}
}
$(document).ready(function(){
id = setInterval(enable,250);
$("#progressbar").progressbar({ value: 0 });
});
var begin = '';
function result(hash){
$("#hash").val(hash);
$("#progressbar").progressbar({ value: 100 });
}
function crypt(){
var salt;
if($("#salt").val().length != 0){
salt = $("#salt").val();
}else{
try{
salt = bcrypt.gensalt($("#rounds").val());
}catch(err){
alert(err);
return;
}
$("#salt").val(salt);
}
try{
$("#progressbar").progressbar({ value: 0 });
bcrypt.hashpw($("#password").val(), $("#salt").val(), result, function() {
var value = $('#progressbar').progressbar( "option", "value" );
$('#progressbar').progressbar({ value: value + 1 });
});
}catch(err){
alert(err);
return;
}
}
</script>
<style type="text/css">
#progressbar {
width: 400px;
}
</style
</head>
<body>
<form >
<label for="password">Password: </label><input size=30 type="text" name="password" id="password"></input>
<br />
<label for="salt">Salt (Optional): </label><input size=30 type="text" name="salt" id="salt"></input>
<br />
<label for="rounds">Rounds: </label>
<select id="rounds" name="rounds">
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
</select>
<br />
<INPUT TYPE="button" NAME="button" value="Waiting for PRNG..." onClick="crypt()" id="submit"/>
<br />
<br />
<label for="hash">Hash: </label><input size=60 type="text" name="hash" id="hash" READONLY></input>
</form>
<div id="progressbar"></div>
</body>
</html>