-
Notifications
You must be signed in to change notification settings - Fork 0
/
test5.html
77 lines (68 loc) · 2.38 KB
/
test5.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
<!DOCTYPE html>
<html>
<title>HTML Tutorial</title>
<head>
<script src="./js/bundle2.js"></script>
<script src="./js/cabundle2.js"></script>
</head>
<body>
<h1 onclick="decryptBtn()">This is a heading</h1>
<p onclick="createWallet()" id="newwallet">This is a paragraph.</p>
<input type="file" id="myFile">
<script>
const inputElement = document.getElementById("myFile");
inputElement.addEventListener("change", handleFiles, false);
function handleFiles() {
const file= this.files[0]; /* now you can work with the file list */
if(file)
{
file.text().then(data=>console.log(data));
}
}
let json = '{"address":"41279f5262bb1db389850489bb0f8f90e958252da2","id":"96777361-cd37-4e5e-a5f3-fc8a60ce5735","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"4d662bf78b9772815d01dc76b2ba9763"},"ciphertext":"0ba12591132f1da422352d130568380cfa64793c163d8dbac584981d8fdf5760","kdf":"scrypt","kdfparams":{"salt":"469c80b760d08caf45e372e24823eaaab23ef6b2d527be550db420409722b84a","n":131072,"dklen":32,"p":1,"r":8},"mac":"799a79e58af9df3ad637ab383a15a50e85ea0bc46db750625bdbe185800221f0"}}';
let passwd ="Ab1234567";
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkCookie() {
var user = getCookie("username");
if (user != "") {
alert("Welcome again " + user);
} else {
user = prompt("Please enter your name:", "");
if (user != "" && user != null) {
setCookie("username", user, 365);
}
}
}
function createWallet()
{
voteitwallet.default.createWallet(0, function(ret){document.getElementById("newwallet").innerHTML=ret.privateKey});
}
function decryptBtn()
{
const myWallet = ethwallet.default.fromV3(json, passwd, true);
console.log("Private Key: " + myWallet.getPrivateKey().toString('hex'))
console.log("Address: " + myWallet.getAddress().toString('hex'))
console.log(ethwallet.decryptKeyStore(json, passwd));
}
</script>
</body>
</html>