Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/Caesar-cipher/Perl/caesar-cipher.pl
Normal file
11
Task/Caesar-cipher/Perl/caesar-cipher.pl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
sub caesar {
|
||||
my ($message, $key, $decode) = @_;
|
||||
$key = 26 - $key if $decode;
|
||||
$message =~ s/([A-Z])/chr(((ord(uc $1) - 65 + $key) % 26) + 65)/geir;
|
||||
}
|
||||
|
||||
my $msg = 'THE FIVE BOXING WIZARDS JUMP QUICKLY';
|
||||
my $enc = caesar($msg, 10);
|
||||
my $dec = caesar($enc, 10, 'decode');
|
||||
|
||||
print "msg: $msg\nenc: $enc\ndec: $dec\n";
|
||||
Loading…
Add table
Add a link
Reference in a new issue