############################################################################ # pwdrot uses the idea of rot13 and expands the characters affected by the # rotations to include all 94 normal printable ascii characters. # ie. chr(33) '!' - chr(126) '~'. The rotations are thus mod 94. # # Used to obfuscate passwords, NOT encrypt them. # # Default rotation, if not supplied, is 47 ############################################################################ sub pwdrot { my $pwd = shift; my $degree = (@_ > 0) ? ((shift) % 94) : 47; if ($degree == 0) { return $pwd; } if (length($str) == 0) { return $pwd; } $rangestr = "\\" . sprintf("%03lo",$degree+33) . "-\\176\\041-\\" . sprintf("%03lo",$degree+32); { local $_; eval { #Can't do string interpolation within 'tr' without 'eval'ing it. $_ = $pwd; eval "tr[\041-\176][$rangestr];"; $_; }; $pwd = $_; } return $pwd; }