-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path31.php
53 lines (40 loc) · 1.28 KB
/
31.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
<pre><?php
/*
vigenère cipher
--> use keyword 'consulting'
--> from character 10 onwards use the result - autokey
https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
*/
$orig = 'usygbjmqeauidgttlcflgqmfqhyhwurqmbxzoqmnpmjhlneqsctmglahp';
$step1 = str_split($orig);
echo 'step1: '.implode(' ', $step1).'
';
$alphabet = 'abcdefghijklmnopqrstuvwxyz';
$keyword = 'consulting';
$step2 = array();
for($i=0; $i<count($step1); $i++) {
if($i < strlen($keyword)) {
$currentKeyCharacter = $keyword[($i%strlen($keyword))];
} else {
$currentKeyCharacter = $step2[($i - strlen($keyword))];
}
$targetPos = strpos($alphabet, $step1[$i]) - strpos($alphabet, $currentKeyCharacter);
if($targetPos>=strlen($alphabet)) {
$targetPos = $targetPos - strlen($alphabet);
} elseif($targetPos<0) {
$targetPos = $targetPos + strlen($alphabet);
}
$step2[] = $alphabet[$targetPos];
}
echo 'step2: '.implode(' ', $step2).'
';
$step3 = implode(' ', $step2);
echo 'step3: '.strrev($step3).'
';
?>
<hr /><hr />
solution:
this person was tricked into sending me numerous vms security holes
answer to the solution:
Neill Clift
</pre>