Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Password (pseudo)casual

by karlgoethebier (Vicar)
on Jan 24, 2013 at 19:29 UTC ( #1015214=note: print w/ replies, xml ) Need Help??


in reply to Password (pseudo)casual

Just a variation on this theme using the buildin features:

#!/usr/bin/perl + use strict; use warnings; my ( @l, @u, @n, @s, @p, $i, $j ); open( URANDOM, "</dev/urandom" ) || die $!; read( URANDOM, $_, 4 ); close URANDOM; srand( unpack( "L", $_ ) ); @l = ( "a" .. "z" ); @u = ( "A" .. "Z" ); # @n = ( 0 .. 9 ); + # @s = ( + # '#', ',', ' ', + # qw( ! " $ % & ' ( ) * + - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ + ) # ); + push( @p, splice( @l, int( rand(@l) ), 1 ) ) for ( 1 .. 10 ); push( @p, splice( @u, int( rand(@u) ), 1 ) ) for ( 1 .. 10 ); # push( @p, splice( @l, int( rand(@l) ), 1 ) ) for ( 1 .. 3 ); + # push( @p, splice( @u, int( rand(@u) ), 1 ) ) for ( 1 .. 3 ); + # push( @p, splice( @n, int( rand(@n) ), 1 ) ) for ( 1 .. 2 ); + # push( @p, splice( @s, int( rand(@s) ), 1 ) ) for ( 1 .. 2 ); + for ( $i = @p ; --$i ; ) { $j = int( rand( $i + 1 ) ); next if $i == $j; @p[ $i, $j ] = @p[ $j, $i ]; } print join( "", @p ) . qq(\n); __END__

Regards, Karl

«The Crux of the Biscuit is the Apostrophe»


Comment on Re: Password (pseudo)casual
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015214]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2015-07-30 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls