# HTML Email obfuscator and colorizer
# derived from a posting by Anatoli Radulov at [id://217611]
use warnings;
use strict;
sub blender {
my ($color1,$color2,$string,$semi)=@_;
$semi=$semi ? ";" : "";
my @chars=split //,$string;
my (@range, @color1, @color2);
#hex2dec;
@color1 = ( $color1 =~ /\#([0-9A-Fa-f][0-9A-Fa-f])
([0-9A-Fa-f][0-9A-Fa-f])
([0-9A-Fa-f][0-9A-Fa-f])/x );
@color2 = ( $color2 =~ /\#([0-9A-Fa-f][0-9A-Fa-f])
([0-9A-Fa-f][0-9A-Fa-f])
([0-9A-Fa-f][0-9A-Fa-f])/x );
$_ = hex($_) foreach @color1,@color2;
#calculate blend ranges
$range[$_] = ($color2[$_] - $color1[$_])/@chars
for (0..2);
@chars=map {
s/ / / || /[\n\b\e]/
? $_
: rand(2)>1
? "".ord($_).";"
: $_
} @chars;
my @insults=map {">$_<"}
qw(spamsucks screwyouspammer scrapethis ihatespammers);
my @res;
for (0..$#chars) {
push(@res,'
') and next
if $chars[$_] eq "\n";
push(@res,'') and next
if $chars[$_] eq "\b";
push(@res,'') and next
if $chars[$_] eq "\e";
push @res, sprintf '%s',
int ($color1[0]+$range[0]*$_),
int ($color1[1]+$range[1]*$_),
int ($color1[2]+$range[2]*$_),
$semi,
$chars[$_];
$res[-1]=qq'$res[-1]'
if rand(5)>1;
push @res,""
if rand(5)>1;
}
return '
'. join("",@res). '
'; } my $string="This is an \bexample\e of what\nit will do"; print blender("#FF0000","#FFFF00",$string); print "Why do the semicolons in the colors below make it look different to the above?\n", "Its the only difference in the two, and I can't work it out.\n", "/msg me with the answer if you can explain the difference!\n", "Cheers.
\n"; print blender("#FF0000","#FFFF00",$string,1);