Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
fuss:sh [2018/04/06 23:56] – [Copyright] officefuss:sh [2019/11/08 16:40] – [Scramble a String] office
Line 751: Line 751:
 The following command will generate an alpha-numeric string from the real random number device that would be suitable to be used as a password: The following command will generate an alpha-numeric string from the real random number device that would be suitable to be used as a password:
 <code bash> <code bash>
-grep -m 10 -ao '[[:alnum:]]' < /dev/urandom | xargs | tr -d ' '+egrep -m 10 -ao '[\x20-\x7E]{1}$' </dev/random | tr -d '\n| wc -c
 </code> </code>
 where:  where: 
-  * ''-m 10'' matches $10$ alpha-numeric characters (''<nowiki>[[:alnum:]]</nowiki>'') from ''/dev/urandom'',+  * ''-m 10'' matches $10$ printable characters (all ASCII characters starting from space ''20'' octal and up to tilde symbol ''7E'' in octal) from ''/dev/urandom'',
   * ''-a'' instructs grep to treat even binary input as characters,   * ''-a'' instructs grep to treat even binary input as characters,
   * ''-o'' instructs grep to only print matches,   * ''-o'' instructs grep to only print matches,
-  * ''<nowiki>[[:alnum:]]</nowiki>'' only matches alpha-numeric characters (this could be a regular expression instead of using GNU bracketed expressions)+  * ''tr'' will be used to delete space charactersand 
-  * ''xargs'' will pass the $10$ extracted alpha-numeric characters as parameters to the next command on the pipe+  * ''wc -c'' will count the characters for verification. 
-  ''tr'' will be used to delete space characters+ 
 +On OSX you can prevent the password to be echoed to the terminal by enqueueing the ''pbcopy'' commandie: 
 +<code bash> 
 +egrep -m 20 -ao '[\x20-\x7E]{1}$</dev/random | tr -d '\n| pbcopy 
 +</code> 
 +which will then place the password in the clipboard.
  
 ====== Detach, Background and Re-Attach a Process ====== ====== Detach, Background and Re-Attach a Process ======
Line 779: Line 784:
  
 Later on, to check up on the command's progress, issue the command ''tmux attach''. Later on, to check up on the command's progress, issue the command ''tmux attach''.
 +
 +====== Scramble a String ======
 +
 +<code bash>
 +echo 'AGsg4SKKs74s62#' | sed 's/./&\n/g' | shuf | tr -d "\n"
 +</code>
 +
 +====== Generate Random Numbers in Range using awk ======
 +
 +<code bash>
 +awk -v min=X -v max=Y 'BEGIN{srand(); print int(min+rand()*(max-min+1))}'
 +</code>
 +where:
 +  * ''X'' is the low number,
 +  * ''Y'' is the high number
 +

fuss/sh.txt · Last modified: 2024/05/12 17:26 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.