Thank you Britgirl.
For anyone interested here’s the modified file:
#!/usr/bin/env perl
use strict;
#
# ./encode_password.pl password
#
my $password = $ARGV[0];
if ($password) {
my $encodedPassword = encodePassword($password);
print “$encodedPassword\n”;
} else {
print “Please provide a password as an argument.\n”;
}
sub encodePassword {
my $p = shift;
my $sPass = “:”;
my $sTmp = “”;
if (!$p) {
return “”;
}
for (my $i = 0; $i < length($p); $i++) {
my $c = substr($p, $i, 1);
my $a = ord($c);
$sTmp = ($a + $i + 1) . “:”;
$sPass .= $sTmp;
$sTmp = “”;
}
return $sPass;
}