-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathindex.html
70 lines (56 loc) · 1.87 KB
/
index.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
<html>
<head>
<title>blowfish</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="Blowfish.js"></script>
<script type="text/javascript" src="http://yandex.st/jquery/1.4.2/jquery.min.js"></script>
<!-- <script type="text/javascript" src="jquery.blowfish.js"></script>-->
</head>
<body>
<form>
<textarea name="text" rows="12" cols="70"></textarea><br/>
<input type="text" name="password" size="56" /><br/>
<input type="submit" name="encrypt" value="Зашифровать">
<input type="submit" name="decrypt" value="Расшифровать"><br/>
<textarea name="result" rows="12" cols="70"></textarea>
</form>
<script type="text/javascript">
$(function() {
$('input[name=encrypt]').submit(function(event) {
event.preventDefault();
});
$('input[name=encrypt]').click(function(event) {
try {
var key = $('input[name=password]').val();
var text = $('textarea[name=text]').val();
var bf = new Blowfish(key);
var res = bf.encrypt(text);
res = bf.base64Encode(res);
$('textarea[name=result]').val(res);
} catch(ex) {
if (window.console && console.log) {
console.log(ex)
}
}
return false;
});
$('input[name=decrypt]').click(function() {
try {
var key = $('input[name=password]').val();
var text = $('textarea[name=text]').val();
var bf = new Blowfish(key);
text = bf.base64Decode(text);
var res = bf.decrypt(text);
res = bf.trimZeros(res);
$('textarea[name=result]').val(res);
} catch(ex) {
if (window.console && console.log) {
console.log(ex)
}
}
return false;
});
});
</script>
</body>
</html>