|< 1 2 >| | 11 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/perl
use strict;
use warnings;
my $variable = 'a b';
$variable =~ s/a/vd/g;
$variable =~ s/b/ff/g;
print $variable . "\n";
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
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @set = map { chomp; split /\s/, $_; } <DATA>;
my %lut; @lut{@set} = (1..36);
my %keys = ( 1 => 'a', 2 => 'd', 3 => 'f', 4 => 'g', 5 => 'v', 6 => 'x' );
#print Dumper \%lut;
print "$_:\t", $lut{$_},
"\tX:", $lut{$_} % 6 ? $lut{$_} % 6 : 6,
"\tY:", $lut{$_} % 6 == 0 ? int($lut{$_} / 6) : int($lut{$_} / 6) + 1,
"\tCode:", $keys{$lut{$_} % 6 ? $lut{$_} % 6 : 6}, " ",
$keys{$lut{$_} % 6 == 0 ? int($lut{$_} / 6) : int($lut{$_} / 6) + 1},
"\n" for (qw /p x d/);
_ _DATA_ _
m l k 1 h g
p 2 o i f u
e r b d t z
5 6 s v 7 j
4 a q 3 c 9
y n 0 w 8 x
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
#!/usr/bin/perl
use strict;
use warnings;
my @Chars = ('a'..'z', 0..9);
my %IndexToADFGVX = (0, 'A', 1, 'D', 2, 'F', 3, 'G', 4, 'V', 5, 'X');
sub gen_keymix {
my @mixed = @Chars;
for(my $i = scalar @mixed; $i > 1;) {
my $r = int(rand($i--));
($mixed[$i], $mixed[$r]) = ($mixed[$r], $mixed[$i]);
}
return @mixed;
}
sub gen_keytable {
my (@mixed) = @_;
my %table = ();
for my $row (0 .. 5) {
for my $col (0 .. 5) {
$table{shift @mixed} = $IndexToADFGVX{$row}.$IndexToADFGVX{$col};
}
}
return %table;
}
sub adfgvx_crypt {
my ($table, $data) = @_;
my $result = join "", map {
$table->{$_},
} split //, $data;
return $result;
}
my @key = &gen_keymix;
my %tab = &gen_keytable(@key);
print adfgvx_crypt(\%tab, 'aperlhacker');
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
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $to_encode = 'a perlhacker';
my $separator = '#';
my $set = [ map { chomp; [split /\s/, $_]; } <DATA> ];
my %keys; @keys{0..5} = qw/a d f g v x/;
my %lut;
for my $row (0 .. 5) {
for my $col (0 .. 5) {
$lut{$set->[$row]->[$col]} = $keys{$row}.$keys{$col};
}
}
my $encoded = join ' ',
map { $lut{$_} ? $lut{$_} : $separator }
split //, $to_encode;
print $encoded, "\n";
_ _DATA_ _
m l k 1 h g
p 2 o i f u
e r b d t z
5 6 s v 7 j
4 a q 3 c 9
y n 0 w 8 x
|< 1 2 >| | 11 Einträge, 2 Seiten |