Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

anyone have any ideas on how to shorten this?

1 view
Skip to first unread message

Eric Waguespack

unread,
Oct 9, 2009, 5:58:42 PM10/9/09
to go...@perl.org
this was an attempt to make a password generator that creates the same
ASCII password every time, given an arbitrary string. (basically 1
password per website)

this is what i have so far:

echo masterpassword gmail.com | perl -MDigest::SHA -ne '$h = $_; for
(1..10) { $h=Digest::SHA::sha512_hex("$h") }; $_=$h; while (/(..)/g) {
$x=$1; $x = int((hex $x) / 2); if( $x ~~ [33..126] ) {print chr($x)};
END {print "\n";};}' | cut -b1-10

I also want to incorporate this, it removes duplicate characters
(irrespective of location), but my current code doesn't let me just
slip it in.

$s =~ s[(.)(?=.*?\1)][]g;

Jasvir Nagra

unread,
Oct 9, 2009, 7:02:46 PM10/9/09
to Eric Waguespack, go...@perl.org
If you have a command line sha1:
echo masterpassword gmail.com | sha1sum | perl -alnF'/(..)/' -e
'@a=map{$_=chr(hex($_)/2);tr/!-~//cd;$_}@F;print@a'

--
Jasvir Nagra
http://www.cs.auckland.ac.nz/~jas

Eric Waguespack

unread,
Oct 9, 2009, 7:05:59 PM10/9/09
to Jasvir Nagra, go...@perl.org
the perl has a loop that rehashes the string 10 times

Jasvir Nagra

unread,
Oct 9, 2009, 7:16:19 PM10/9/09
to Eric Waguespack, go...@perl.org
Sure. It wasn't clear what the value of that was other than slowing things
down (which may of course be of value).

John W. Krahn

unread,
Oct 9, 2009, 11:37:50 PM10/9/09
to go...@perl.org
Eric Waguespack wrote:
> this was an attempt to make a password generator that creates the same
> ASCII password every time, given an arbitrary string. (basically 1
> password per website)
>
> this is what i have so far:
>
> echo masterpassword gmail.com | perl -MDigest::SHA -ne '$h = $_; for
> (1..10) { $h=Digest::SHA::sha512_hex("$h") }; $_=$h; while (/(..)/g) {
> $x=$1; $x = int((hex $x) / 2); if( $x ~~ [33..126] ) {print chr($x)};
> END {print "\n";};}' | cut -b1-10

echo masterpassword gmail.com | perl -MDigest::SHA=sha512_hex
-lpe'{$_=sha512_hex($_);++$x<10&&redo}s!(..)!$_=chr
hex($1)/2;y|\41-\177||?$_:""!eg;s/(.)(?=.*?\1)//sg;$_=substr$_,0,10'

John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity. -- Damian Conway

0 new messages