#!/usr/bin/perl # affine.pl # usage, to transform the phrase "THE SECRET WORD IS PASTA" by the map x -> 3*x + 13: # echo "THE SECRET WORD IS PASTA" | affine.pl 3 13 $a = $ARGV[0]; $b = $ARGV[1]; $plaintext = ; $plaintext =~ s/\s+//g; @chars = split('',$plaintext); for $c (@chars) { print chr(($a*(ord($c)-ord("A"))+$b)%26+ord("A")); } print "\n";