You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.7 KiB
69 lines
1.7 KiB
<!-- Copyright 2023 by Alexei Bezborodov <AlexeiBv+mirocod_wave_reflection@narod.ru> --> |
|
<!-- public domain --> |
|
|
|
<html lang="ru"> |
|
|
|
<head> |
|
<meta charset="UTF-8"> |
|
<title>Генерация ключа</title> |
|
|
|
<!-- |
|
Загрузка скриптов из интернета |
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.8.9/brython.min.js"></script> |
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.8.9/brython_stdlib.js"></script> |
|
--> |
|
|
|
<!-- |
|
Загрузка скриптов из локальной папки (рядом с файлом html) |
|
--> |
|
<script type="text/javascript" src="brython.min.js"></script> |
|
<script type="text/javascript" src="brython_stdlib.js"></script> |
|
|
|
|
|
</head> |
|
|
|
<body onload="brython()"> |
|
|
|
<h1 class="text-center">Генерация случайного ключа</h1> |
|
|
|
Символы для генерации ключа |
|
<input id = "words" value="0123456789ABCDEF"/> |
|
<br/> |
|
|
|
Размер ключа |
|
<select size="1" id="key_size"> |
|
<option>64</option> |
|
<option>128</option> |
|
<option selected="selected">256</option> |
|
<option>512</option> |
|
</select> |
|
|
|
<br/> |
|
|
|
<input type="button" id="gen_key" value="Сгенерировать ключ"></input> |
|
|
|
<p id="output"></p> |
|
|
|
<script type="text/python"> |
|
|
|
from browser import document, html, window |
|
import random, math |
|
|
|
def gen_key(size): |
|
result = '' |
|
words = document["words"].value |
|
for i in range(size // 4): |
|
result += words[random.randint(0, len(words) - 1)] |
|
return result |
|
|
|
def gen_key_event(event): |
|
document["output"].innerHTML = gen_key(int(document["key_size"].value)) |
|
|
|
|
|
document["gen_key"].bind("click", gen_key_event) |
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html>
|
|
|