Monday, October 9. 2006Password generator in bash![]()
#!/bin/bash
# Number of letters as argument, default 7 if [ “$1” != “” ]; then num=$1 else num=7 fi generate() { # Take 1 block from /dev/urandom, encode it base64, # remove first two and last status line, purge capital letters and # special characters from output, cut desired length from front # sed with [A-Z] doesn’t work with Suse - typical! password=$(dd if=/dev/urandom count=1 2>/dev/null | uuencode -m - \ | head -n 2 | tail -n 1 | sed -e ’s:[/+A-Z]::g’ | cut -c -$num) } # Repeat until letters AND digits occur while true; do generate if echo $password | grep [a-z] | grep [0-9]; then break; fi done
Posted by Stephan Paukner
in GNU/Linux
at
07:43
| Comments (0)
| Trackbacks (0)
Defined tags for this entry: bash, programming
(Page 1 of 1, totaling 1 entries)
|
AboutCalendar
ArchivesCategoriesShow tagged entriesandroid anti-spam apache astronomy austria automobile ballooning bash bluetooth bug career cloud collecting comic cooking crypto cw debian diy dreams education electronics event fail fashion finance flickr fuerteventura fun gentoo geography german gnu-linux google google earth guitar hardware history image processing internet kernel kids language lanzarote lhc lifestyle linkroll literature ltd machine learning making mallorca mathematics matlab microsoft migration movies munich music nautilus octave pdf perl philately philosophy phone photo gear photography podcast politics postfix private programming public transport rant religion review salzburg samsung science security shtf social web software statistics storage sustainability symbian tablet time lapse transceiver tv usenet venice video virtualization wordplay work www yahoo
Syndicate This BlogFollow meBookmarksPowered by |