Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZA
CDEFGHIJKLMNOPQRSTUVWXYZAB
DEFGHIJKLMNOPQRSTUVWXYZABC
EFGHIJKLMNOPQRSTUVWXYZABCD
FGHIJKLMNOPQRSTUVWXYZABCDE
etc...
blackblackblackblackblack
fourscoreandsevenyearsago
sub vignere($$) {
my @ciphered;
my($keyword,$text) = @_;
$keyword =~ s/[^A-Za-z]//g;
$text =~ s/[^A-Za-z]//g;
my @keyChars = split //, $keyword;
my @plaintextChars = split //, $text;
my $j = 0;
my $max = @keyChars;
foreach my $p(@plaintextChars) {
my $k = $keyChars[$j];
unless(++$j < $max) { $j = 0; }
my $horizontal = indexOf($k);
my $vertical = indexOf($p);
my @alphabet = rotate($horizontal);
my $cipherText = $alphabet[$vertical];
push(@ciphered,$cipherText);
}
@ciphered;
}
sub rotate($) {
my $pos = shift;
my @charArray = ('A'..'Z');
for($i = 0; $i < $pos; $i++) {
push(@charArray,shift(@charArray));
}
@charArray;
}
sub indexOf($) {
my $char = shift;
my @charArray = ('A'..'Z');
my $index;
for ($i=0; $i < @charArray; $i++) {
if ($charArray[$i] eq uc $char) {
$index = $i;
last;
}
}
$index;
}
sub vignere($$) {
my @ciphered;
my($keyword,$text) = @_;
$_ =~ s/[^A-Za-z]//g for ($text,$keyword);
my @keyChars = split //, $keyword;
my @plaintextChars = split //, $text;
my $j = 0;
my $max = @keyChars;
foreach $p(@plaintextChars) {
my $k = $keyChars[$j];
unless(++$j < $max) { $j = 0; }
my $horizontal = ord(uc $k) - 65;
my $vertical = ord(uc $p) - 65;
my @alphabet = rotate($horizontal);
my $cipherText .= $alphabet[$vertical];
push(@ciphered,$cipherText);
}
@ciphered;
}
sub rotate($) {
my $pos = shift;
my @charArray = ('A'..'Z');
for($i = 0; $i < $pos; $i++) {
push(@charArray,shift(@charArray));
}
@charArray;
}
sub vignere($$) {
my @ciphered;
my($keyword,$text) = @_;
$_ =~ s/[^A-Za-z]//g for ($text,$keyword);
my @keyChars = split //, $keyword;
my @plaintextChars = split //, $text;
my $j = 0;
my $max = @keyChars;
foreach my $p(@plaintextChars) {
my $k = $keyChars[$j];
unless(++$j < $max) { $j = 0; }
my $cipherText = chr((ord(uc $k) + ord(uc $p))%26 + 65);
push(@ciphered,$cipherText);
}
@ciphered;
}
sub vignere($$) {
my($keyword,$text) = (uc shift,uc shift);
$_ =~ s/[^A-Za-z]//g for ($text,$keyword);
my @keyChars = split //,$keyword;
my @plaintextChars = split //,$text;
map{ chr((ord($plaintextChars[$_])+ord($keyChars[$_%@keyChars]))%26+65) } 0..@plaintextChars-1;
}