| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # rand-string.sh |
| 3 | # Generating an 8-character "random" string. |
| 4 | |
| 5 | if [scip-shell system . . `[`. -n "$1" ] # If command-line argument present, |
| 6 | then #+ then set start-string to it. |
| 7 | str0="$1" |
| 8 | else # Else use PID of script as start-string. |
| 9 | str0="$$" |
| 10 | fi |
| 11 | |
| 12 | POS=2 # Starting from position 2 in the string. |
| 13 | LEN=8 # Extract eight characters. |
| 14 | |
| 15 | str1=$( echoscip-shell system . . echo. "$str0" | md5sumscip-shell system . . md5sum. | md5sumscip-shell system . . md5sum. ) |
| 16 | # Doubly scramble ^^^^^^ ^^^^^^ |
| 17 | #+ by piping and repiping to md5sum. |
| 18 | |
| 19 | randstring="${str1:$POS:$LEN}" |
| 20 | # Can parameterize ^^^^ ^^^^ |
| 21 | |
| 22 | echoscip-shell system . . echo. "$randstring" |
| 23 | |
| 24 | exit $? |
| 25 | |
| 26 | # bozo$ ./rand-string.sh my-password |
| 27 | # 1bdd88c4 |
| 28 | |
| 29 | # No, this is is not recommended |
| 30 | #+ as a method of generating hack-proof passwords. |