-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpasshash.js
More file actions
64 lines (62 loc) · 1.27 KB
/
passhash.js
File metadata and controls
64 lines (62 loc) · 1.27 KB
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
var state = {
seed: "",
key: "",
len: 32,
hash: "",
setSeed: function(v) {
state.seed = v;
},
setKey: function(v) {
state.key = v;
},
setLen: function(v) {
state.len = parseInt(v, 10);
},
toHash: function() {
state.hash = blake2b.blake2bHex(state.seed, state.key, state.len / 2);
}
};
var Component = {
view: function() {
return [
m("h1", "PassHash"),
m("div", [
"Seed: ",
m("input", {
type: "password",
size: "50",
oninput: m.withAttr("value", state.setSeed),
value: state.seed
})
]),
m("div", [
"Keys: ",
m("input", {
type: "text",
size: "50",
oninput: m.withAttr("value", state.setKey),
value: state.key
})
]),
m("div", [
"Length: ",
m(
"select",
{
onchange: m.withAttr("value", state.setLen)
},
[8, 16, 32, 64].map(function(v) {
return m("option", { value: v, selected: state.len == v }, v);
})
)
]),
m("input", {
type: "button",
onclick: state.toHash,
value: "Submit"
}),
m("div", state.hash)
];
}
};
m.mount(document.body, Component);