-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkey-generation.php
101 lines (93 loc) · 2.97 KB
/
key-generation.php
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
<?php
// Fetch the BIP-39 word list from the provided URL
$wordListUrl = 'https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt';
$wordList = file($wordListUrl, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// Function to generate random words
function generateRandomWords($wordList, $numWords = 19) {
$words = [];
for ($i = 0; $i < $numWords; $i++) {
$words[] = $wordList[array_rand($wordList)];
}
return implode(' ', $words);
}
// Generate random words and their hash
$randomWords = generateRandomWords($wordList, 19);
$hashedWords = hash('sha512', $randomWords);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Key Generator</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
.container {
max-width: 600px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
.result {
margin: 20px 0;
padding: 15px;
background-color: #e7f3fe;
border-left: 6px solid #2196F3;
}
.instructions {
margin-top: 20px;
padding: 10px;
background-color: #fff3cd;
border-left: 6px solid #ffeeba;
}
button {
background-color: #2196F3;
color: white;
border: none;
padding: 10px 15px;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #1976D2;
}
</style>
</head>
<body>
<div class="container">
<h1>Key Generator</h1>
<div class="result">
<strong>Your Seeds:</strong> <span id="generatedWords"><?php echo htmlspecialchars($randomWords); ?></span><br>
<strong>Your Address:</strong> <span id="hashedWords"><?php echo htmlspecialchars($hashedWords); ?></span><br>
<button onclick="copyToClipboard('generatedWords')">Copy Seeds</button>
</div>
<div class="instructions">
<h2>Instructions:</h2>
<p>Please keep your generated seeds/words secure and do not share them publicly.
If someone gains access to your seeds, they can control your account.</p>
<p>Ensure that there are no extra spaces between words when copying, as this may cause an invalid key error.</p>
</div>
</div>
<script>
function copyToClipboard(elementId) {
const textToCopy = document.getElementById(elementId).innerText;
navigator.clipboard.writeText(textToCopy).then(() => {
alert('Seeds copied to clipboard!');
}).catch(err => {
console.error('Could not copy text:', err);
});
}
</script>
</body>
</html>