-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path16.php
89 lines (69 loc) · 2.09 KB
/
16.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
<pre><?php
/*
step 1 - rotary dial cipher
--> 0 translates to 'q' and 'z'
https://en.wikipedia.org/wiki/Rotary_dial#/media/File:Rotarydial.JPG
step 2 - vigenère cipher
--> use keyword 'heinz'
https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
*/
$alphabet1 = array(
0 => array('q', '.', 'z'),
2 => array('a', 'b', 'c'),
3 => array('d', 'e', 'f'),
4 => array('g', 'h', 'i'),
5 => array('j', 'k', 'l'),
6 => array('m', 'n', 'o'),
7 => array('p', 'r', 's'),
8 => array('t', 'u', 'v'),
9 => array('w', 'x', 'y'),
);
$orig = '7\3|2\9|3\5|4/0/8/2|6\7/0/4\4\5/6/6\5/7/8/9|7\8/7|9\5/9\2\3\5\7/8|2/0/8|2/6|6|2|7\7\0\4\9|';
$step1 = array();
for($i=0; $i<strlen($orig); $i+=2) {
if($orig[$i+1] == '\\') {
$tmp = 0;
} elseif($orig[$i+1] == '|') {
$tmp = 1;
} elseif($orig[$i+1] == '/') {
$tmp = 2;
}
$step1[] = array(
$orig[$i].$orig[$i+1],
$alphabet1[$orig[$i]][$tmp]
);
}
echo 'step 1 - rotary dial cipher:
';
foreach($step1 as $value) {
echo strtoupper($value[0]).' ';
}
echo '
';
foreach($step1 as $value) {
echo strtoupper($value[1]).' ';
}
echo '
step 2 - vigenère cipher
';
$alphabet2 = 'abcdefghijklmnopqrstuvwxyz';
$keyword = 'heinz';
for($i=0; $i<count($step1); $i++) {
$targetPos = strpos($alphabet2, $step1[$i][1]) - strpos($alphabet2, $keyword[($i%strlen($keyword))]);
if($targetPos>=strlen($alphabet2)) {
$targetPos = $targetPos - strlen($alphabet2);
} elseif($targetPos<0) {
$targetPos = $targetPos + strlen($alphabet2);
}
$output .= $alphabet2[$targetPos];
}
echo $output;
?>
<hr /><hr />
solution:
i asked eric for the key to this phone company facility
answer to the solution:
Pacific Bell central office
I wasn't going to tell him what I wanted it for, but my
plan was to get into the Calabasas central office.
</pre>