#!/usr/bin/perl # # singlepass 1.0 # # This script will generate passwords given a Single Pass password # and a Service Name. # # Copyright 2012 - Paul E. Jones # All Rights Reserved # use strict; use IO::Prompt; use Digest::SHA qw(sha256); # # MAIN # { my ($single_password, $service_name, $service_password, $digest); my @pwchars = ( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ); binmode(STDIN, ":encoding(UTF-8)"); $single_password = prompt("Single Password: ", -e => "*"); $service_name = prompt("Service Name: "); if ((length($single_password) == 0) || (length($service_name) == 0)) { die "Invalid input provided\n"; } $digest = sha256($single_password . ":" . $service_name); $service_password = ""; for(my $i=0; $i < 16; $i++) { my $j = unpack("C", substr($digest, $i, 1)); $service_password .= $pwchars[$j % 62]; } print "Service Password: $service_password\n"; }