Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
SCRIPT: A strong cryptographically passwd phrase generator.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
likewhoa
l33t
l33t


Joined: 04 Oct 2006
Posts: 778
Location: Brooklyn, New York

PostPosted: Sat Aug 04, 2007 8:26 am    Post subject: SCRIPT: A strong cryptographically passwd phrase generator. Reply with quote

Here is a function which utilizes the Kernel's /dev/random to generate pseudorandom characters, then passed to uuencode to convert any binary characters to text encoding, after we use sed to just print the second line which is the output from uuencode and tr will add spacing "to become a password phrase" after each character.. last but not least, we trim the output to match length input.

example of usage: ranpasswd <LENGTH> <CHAR EXCLUDE>

create a 24 character password phrase and add spacing after every character containing "likewhoa".
this sample we run the same command 7 times to show randomness.
Code:

darko:~-> ranpasswd 24 likewhoa
Cr9hhRtt jfiVnRyk o3QfZq
your generated password phrase is above.
darko:~-> ranpasswd 24 likewhoa
vDZ50Cg0PHL4TpUJSoCv5p 6
your generated password phrase is above.
darko:~-> ranpasswd 24 likewhoa
bDZ01 Zvg 9WaUv4kLv853N6
your generated password phrase is above.
darko:~-> ranpasswd 24 likewhoa
 +a N4 WF7jb6DLVy4n  S R
your generated password phrase is above.
darko:~-> ranpasswd 24 likewhoa
zqq7FP  IEhy/Z8yvSWw 4y0
your generated password phrase is above.
darko:~-> ranpasswd 24 likewhoa
 L5LE 2 wBf qCCTyTh1mOOr
your generated password phrase is above.
darko:~-> ranpasswd 24 likewhoa
29Q RjPA+ bgzw7  7Fo0 W
your generated password phrase is above.
darko:~->


FUNCTION:
Code:

ranpasswd() {
        local length="$1"
        local excludes="$2"
        local x=$(($length+10))
        local y=$(($x-10))
       
        head -c $length /dev/random | uuencode -m - | sed -n 2p | tr '[=$excludes]' ' ' | head -c $y
        echo -e "\nyour generated password phrase is above."
}


DEPENDENCY:
app-arch/sharutils needed for uuencode.


enjoy it, next would be to be able to automate this password utilities.
Back to top
View user's profile Send private message
tobr
Guru
Guru


Joined: 29 May 2006
Posts: 330

PostPosted: Mon Aug 06, 2007 4:03 pm    Post subject: Reply with quote

That’s a very helpful script. But also check out app-admin/makepasswd which also uses /dev/random. It has some interesting features like making several passwords, hash them with MD5, select the characters you want the password to consist of and random (between X and Y characters) length.

Enjoy.
_________________
Please add [SOLVED] to your message title if your problem is solved.

Death to all blobs!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum