-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.php
114 lines (85 loc) · 5.15 KB
/
test.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
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
require_once 'encrypt_decrypt.php';
// These keys were generated with keygen.php
$public_key = <<<END_PUB
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApzrxdVWcyq43FEkSF2XN
UfsyGUyimYZFkqwzqrfPRzRd12tf871U7PHRPNeiOO2zJIpMcMSxwPPRmS5jA6nW
xELhuSA+99QZFRkoxsEoneYvhwL6dzJ7fzT/QHnADrKA0s538ymBsnfl+LbPRxFt
qarYav7ImE41P7vtKXqjPYZX1a4jTHZRht0l+3GXSNwvOxQUinYEm6GKus2sO8gz
6b/VHCGwB9z90pHFee09aFg5eXjJr7bcs1HyWiLT0s/+/DLncGZxURh6/AxDdG+R
rjqZSTmPR+Rn2fkkdpudHmChMI7RjV/Hp3NsfIb53tBy1r3FDbx2NpLN6iuju3m3
vQIDAQAB
-----END PUBLIC KEY-----
END_PUB;
$private_key = <<<END_PRI
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEApzrxdVWcyq43FEkSF2XNUfsyGUyimYZFkqwzqrfPRzRd12tf
871U7PHRPNeiOO2zJIpMcMSxwPPRmS5jA6nWxELhuSA+99QZFRkoxsEoneYvhwL6
dzJ7fzT/QHnADrKA0s538ymBsnfl+LbPRxFtqarYav7ImE41P7vtKXqjPYZX1a4j
THZRht0l+3GXSNwvOxQUinYEm6GKus2sO8gz6b/VHCGwB9z90pHFee09aFg5eXjJ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IvaTrnpnEOwgvS6ud2U4HZqMqD
XAChlEcO5UjHGn3wn8Wpskh/GvYVr1RIaU5dAHOOJITIAhKL2KzyK1f00+5ZDiqq
JKdxAoGAHVbr6A3uzK7c6vHlgDpSzHWSM6fO553tR6vAm870hM5dE3BMgr6JcBng
tHZ1OCxCPQTJly2Vfj46r/sxctageCabbvY/GaGmPjr8lXzIiJ5ZCyP/8+RQ7Vqb
wUfPK/FxKQd7wsJCWu7GVx3idKA5aUbD8RQX4Ou7Az8iYDXLUd4=
-----END RSA PRIVATE KEY-----
END_PRI;
// These are some instrctions I found for the Enigma machine ... it seemd appropriate
// Credit: http://www.ilord.com/enigma-manual1937-english.html
$plaintext = <<<END_PLAIN
1937 Enigma Manual - English Translation
I. General.
1. The Enigma encryption machine is a secret object in terms of the secret item regulation
(Verschlußsachen-Vorschrift) (II. Dv. 99). According to the regulations of this provision, it is to be kept
locked up.
2. Every user of the encryption machine must be aware of the fact that the construction of the machine requires
careful usage and maintenance, so that the machine is ready for use at any time.
II. Preparation for Using the Machine.
3. Before starting the machine, it is to be checked for proper operation. For this, the wooden protection box is
to be opened, the holding fixture (Picture I, 1) to be opened by lifting the spring-loaded buttons (I, 2),
the holding levers (I, 3) to be pivoted down, whereupon the cover plate (I/II, 4) can be opened which exposes
the thumbwheel (II/IV,5).
4. The thumbwheels (II/IV, 5) are to be rotated against each other, so that the contacts of the encryption
cylinders become bare. Subsequently, the cover plate (I/II, 4) is to be closed and secured by the the holding
levers (I, 3).
5. To clean the key contacts, all keys (II, 6) are to be pressed down firmly multiple times, and let snap back
rapidly. While doing this, one key is to be held down to avoid unnecessary progression of the cylinders.
6. The battery switch (II, 7) is to be set to „dunkel" (dark) when the battery is fresh. As soon as the battery
voltage degrades after long use, the setting „hell" (light) is to be used for improved brightness of the bulbs.
Using the setting „hell" too early will lead to premature bulb burn out.
7. In bright sunshine, and to spare the user’s eyes, it is advisable to remove the green Zellon panel (I/II, 8)
from the wooden cover by lifting and turning the spring-loaded buttons (I/II, 9), and to secure it on top of the
transparent letters using the same mechanism. The Zellon panel attenuates the light of the bulbs and covers all
letters so that only the lit letter is visible.
8. For protection against bright sunlight the device can be shaded through pulling the joints of the cover
hinge (II, 14) out towards the front, and closing the wooden cover down partially.
9. There is a sheet holder (I, 42) on the inside of the wooden cover that allows documents to be held
comfortably in front of the operators eyes during encryption.
END_PLAIN;
echo '<pre>';
echo "Starting Plaintext:\n$plaintext";
echo "\n --- \n";
$ciphertext = encrypt_message($plaintext,$public_key);
echo "\nCiphertext:\n";
echo chunk_split($ciphertext);
$plaintext2 = decrypt_message($ciphertext,$private_key);
echo "\n\nDecrypted Back into Plaintext\n\n";
echo $plaintext;
?>