Skip to content

Instantly share code, notes, and snippets.

@whoo
Last active June 29, 2016 01:36
Show Gist options
  • Save whoo/47ee1d2f863f9fb1d57c50698dd8510f to your computer and use it in GitHub Desktop.
Save whoo/47ee1d2f863f9fb1d57c50698dd8510f to your computer and use it in GitHub Desktop.
CheckPassword Compliance
#!/usr/bin/perl
$Pwd=$ARGV[0];
$MinPwd=8;
chop($Pwd);
if ($Pwd=~/[[:upper:]]/) { $maj=1; } else { $maj=0; }
if ($Pwd=~/[[:digit:]]/) { $dig=1; } else { $dig=0; }
if ($Pwd=~/[[:punct:]]/) { $car=1; } else { $car=0; }
if ($Pwd=~/[[:lower:]]/) { $min=1; } else { $min=0; }
if ($Pwd=~/[[:space:]]/) { $spc=1; } else { $spc=0; }
$length=length($Pwd);
$len=$length;
#if($length <= $MinPwd) {$length=$MinPwd-1;}
$numcar=($maj*26+$dig*10+$car*31+$min*26+$spc*3);
$h= $length * log($numcar)/log(2);
print $length," ",$numcar,"\n";
print "Entropy: ",ceil($h);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment