-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
152 lines (134 loc) · 5.4 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="damartripamungkas" />
<meta
name="description"
content="A cryptocurrency wallet with customized private keys generated from words"
/>
<title>Custom Key Wallet Crypto</title>
<link rel="apple-touch-icon" sizes="180x180" href="./public/favicon/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="./public/favicon/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="./public/favicon/favicon-16x16.png" />
<link rel="manifest" href="./public/favicon/site.webmanifest" />
<link rel="stylesheet" href="./public/css/style.css" />
</head>
<body>
<div class="container">
<div class="card">
<h1 class="mt-0">Custom Key Wallet Crypto</h1>
<p class="mb-0-5">creator: damartripamungkas</p>
<p class="mb-0-5">donation address: 0x106afd8f747687876fa9b096ff20a78620621af3</p>
<a class="mb-0-5" href="https://github.com/damartripamungkas/custom-key-wallet-crypto"
>repository: https://github.com/damartripamungkas/custom-key-wallet-crypto</a
>
</div>
<div class="card">
<p class="mb-0-5">Reinforcement Before iterations</p>
<select id="select-1" aria-label="select-1">
<option value="1" selected>
1. keccak256(words) + sha512(words.slice(0, words.length / 2))
</option>
<option value="2">disable</option>
</select>
<p class="pt-10 mb-0-5">Number of iterations</p>
<input id="input-1" type="number" value="3" aria-label="input-1" />
<p class="pt-10 mb-0-5">Enter the words you want to use</p>
<textarea id="input-2" aria-label="input-2"></textarea>
<p class="pt-10 mb-0-5">Result privatekey with and without prefix 0x</p>
<textarea class="w-full click-able" id="result-1" aria-label="result-1" disabled></textarea>
<textarea
class="w-full click-able mt-2-5"
id="result-2"
aria-label="result-2"
disabled
></textarea>
<p class="pt-10 mb-0-5">Result address wallet</p>
<input class="click-able" id="result-3" aria-label="result-3" disabled />
<!-- <button id="copy-result-3" class="mt-2">Copy</button> -->
</div>
</div>
<script type="module">
import { toUtf8Bytes, keccak256, sha512, Wallet } from "./public/js/ethers.min.js";
const hashWords = (str, iterations, numMethod) => {
let pk = str;
if (numMethod == "1") {
// 1. keccak256(words) + sha512(words.slice(0, words.length / 2))
pk = keccak256(toUtf8Bytes(pk)) + sha512(toUtf8Bytes(pk.slice(0, pk.length / 2)));
}
// Hash interation results other than 1 will include the prefix "0x" to be hashed
const pkN = keccak256(toUtf8Bytes(pk));
pk = pkN;
for (let index = 1; index < iterations; index++) {
pk = keccak256(toUtf8Bytes(pk));
}
return pk;
};
const createWallet = (str, iterations, numMethod) => {
const pk = hashWords(str, iterations, numMethod);
const { address } = new Wallet(pk);
return {
get evm() {
return { pk, address: address.toLowerCase() };
},
get nonEvm() {
return { pk: pk.slice(2), address: address.toLowerCase() };
},
};
};
const select1 = document.getElementById("select-1");
const input1 = document.getElementById("input-1");
const input2 = document.getElementById("input-2");
const result1 = document.getElementById("result-1");
const result2 = document.getElementById("result-2");
const result3 = document.getElementById("result-3");
const state = {
numberIterations: parseInt(input1.value),
select1Value: select1.value,
};
const hashNow = () => {
const value = input2.value;
if (value.length == 0) {
result1.textContent = "";
result2.textContent = "";
result3.value = "";
return;
}
const select1Value = state.select1Value;
let numberIterations = state.numberIterations;
if (numberIterations.length == 0 || parseInt(numberIterations) <= 0) {
numberIterations = 1;
}
const { evm, nonEvm } = createWallet(value, numberIterations, select1Value);
result1.textContent = evm.pk;
result2.textContent = nonEvm.pk;
result3.value = evm.address;
};
select1.onchange = () => {
state.select1Value = select1.value;
hashNow();
};
input1.oninput = () => {
if (input1.value.length <= 0) {
result1.textContent = "";
result2.textContent = "";
result3.value = "";
return;
}
if (input1.value > 1000) input1.value = 1000;
if (input1.value <= 0) input1.value = 1;
state.numberIterations = input1.value;
hashNow();
};
input2.oninput = hashNow;
const btnCopyResult3 = document.getElementById("copy-result-3");
btnCopyResult3.oninput = () => {
result3.select();
result3.setSelectionRange(0, 99999); // For mobile devices
navigator.clipboard.writeText(result3.value);
};
</script>
</body>
</html>