-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
52 lines (46 loc) · 1.83 KB
/
index.html
File metadata and controls
52 lines (46 loc) · 1.83 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Onion Address Generator</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Onion Address Generator</h1>
<button onclick="generateOnionAddress()">Start</button>
<div id="results"></div>
<script src="crypto-js.js"></script>
<script src="elliptic.min.js"></script>
<script src="base32.js"></script>
<script>
function generateOnionAddress() {
const EC = require('elliptic').ec;
const ec = new EC('ed25519');
// Generate private key
const key = ec.genKeyPair();
const privateKey = key.getPrivate('hex');
// Generate public key
const publicKey = key.getPublic().encode('hex');
// Hash the public key using SHA3-256
const hash = CryptoJS.SHA3(publicKey, { outputLength: 256 }).toString(CryptoJS.enc.Hex);
// Take the first 80 bits (10 bytes)
const hash80bits = hash.substring(0, 20);
// Convert to base32
const base32 = require('hi-base32');
const onionAddress = base32.encode(Buffer.from(hash80bits, 'hex')).toLowerCase().replace(/=/g, '') + ".onion";
// Display results
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = `
<div class="container">
<h2>New Address Generated</h2>
<pre>Private Key: ${privateKey}</pre>
<pre>Public Key: ${publicKey}</pre>
<pre>Onion Address: ${onionAddress}</pre>
</div>
` + resultsDiv.innerHTML;
}
</script>
<script src="script.js"></script>
</body>
</html>