-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen.php
40 lines (36 loc) · 920 Bytes
/
gen.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
<?php
if ($_SERVER["argv"][1] === "gen_file") {
file_put_contents("test_folder/aaa.txt", "Hello World! AAAAAAA");
file_put_contents("test_folder/bbb.txt", "Hello World! BBBBBBB");
exit;
}
$a = "1234567890-=!@#$%^&*()_+QWERTYUIOP[]\qwertyuiop{}|asdfghjkl;'ASDFGHJKL;'XCVBNM,./xcvbnm<>Zz";
$a = str_split($a);
$a = array_unique($a);
$b = $a;
shuffle($b);
$b = array_values($b);
$a = array_values($a);
$orig_b = $b;
// Encrypt map
foreach ($a as $k => $v) {
if (in_array($v, ["'", "\\"])) {
$v = "\\".$v;
}
if (in_array($b[$k], ["'", "\\"])) {
$b[$k] = "\\'";
}
echo "['{$v}'] = '{$b[$k]}',\n";
}
echo "--------------------------------\n";
$b = $orig_b;
// Decrypt map
foreach ($b as $k => $v) {
if (in_array($v, ["'", "\\"])) {
$v = "\\".$v;
}
if (in_array($a[$k], ["'", "\\"])) {
$a[$k] = "\\'";
}
echo "['{$v}'] = '{$a[$k]}',\n";
}