{"id":1031,"date":"2020-05-10T03:39:57","date_gmt":"2020-05-10T02:39:57","guid":{"rendered":"https:\/\/codedoneright.eu\/?page_id=1031"},"modified":"2021-01-01T19:12:54","modified_gmt":"2021-01-01T18:12:54","slug":"random-password-generator","status":"publish","type":"page","link":"https:\/\/codedoneright.eu\/?page_id=1031","title":{"rendered":"Random Password Generator"},"content":{"rendered":"\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>This is a random password generator script for Bash. It generates a password with 1 special character, 1 number, 1 lowercase letter, 1 uppercase letter and 9-16 additional characters from a combination of numbers, lowercase and uppercase letters. Note that I excluded &#8220;0&#8221; zero, &#8220;i&#8221; and &#8220;l&#8221; to avoid confusion.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\nif  &#91;&#91; $1 = -m ]]; then\n\tfor i in `seq $2`;\n\tdo\n\t\tchoose() { echo ${1:RANDOM%${#1}:1} $RANDOM; }\n\n\t\t{\n    \t\tchoose '!@#$%&amp;'\n    \t\tchoose '0123456789'\n    \t\tchoose 'abcdefghijklmnopqrstuvwxyz'\n    \t\tchoose 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n    \t\tfor i in $( seq 1 $(( 8 + RANDOM % 8 )) )\n    \t\tdo\n        \t\tchoose '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\n    \t\tdone\n\n\t\t} | sort -R | awk '{printf \"%s\",$1}'\n\t\techo \"\"\n\tdone\nelse\n\nchoose() { echo ${1:RANDOM%${#1}:1} $RANDOM; }\n\n{\n    choose '!@#$%&amp;'\n    choose '0123456789'\n    choose 'abcdefghijklmnopqrstuvwxyz'\n    choose 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n    for i in $( seq 1 $(( 8 + RANDOM % 8 )) )\n    do\n        choose '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\n    done\n\n} | sort -R | awk '{printf \"%s\",$1}'\necho \"\"\n\nfi<\/code><\/pre>\n\n\n\n<p>If you want to change the length of the password then modify the following line<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for i in $( seq 1 $(( 8 + RANDOM % 8 )) <\/code><\/pre>\n\n\n\n<p>First <em>8<\/em> is the fixed number of generated characters and the second <em>8<\/em> indicates a random number of additional characters, up to an additional 8 characters.<\/p>\n\n\n\n<p>In order to generate multiple passwords, run the script with <strong>-m #<\/strong> option, where <strong>#<\/strong> is the number of passwords that you want to generate. Like so<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/foo.sh -m X<\/code><\/pre>\n\n\n\n<p>In order to save generated passwords to a file, redirect output of the script like so<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/foo.sh -m X &gt; file.txt<\/code><\/pre>\n\n\n\n<p>This will create a file named <em>file.txt<\/em> that will contain your fresh passwords.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a random password generator script for Bash. It generates a password with 1 special character, 1 number, 1 lowercase letter, 1 uppercase letter and 9-16 additional characters from a combination of numbers, lowercase and uppercase letters. Note that&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":414,"menu_order":15,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Random Password Generator &#8212; Code Done Right!<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codedoneright.eu\/?page_id=1031\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Random Password Generator &#8212; Code Done Right!\" \/>\n<meta name=\"twitter:description\" content=\"This is a random password generator script for Bash. It generates a password with 1 special character, 1 number, 1 lowercase letter, 1 uppercase letter and 9-16 additional characters from a combination of numbers, lowercase and uppercase letters. Note that&hellip;\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=1031\",\"url\":\"https:\/\/codedoneright.eu\/?page_id=1031\",\"name\":\"Random Password Generator &#8212; Code Done Right!\",\"isPartOf\":{\"@id\":\"https:\/\/codedoneright.eu\/#website\"},\"datePublished\":\"2020-05-10T02:39:57+00:00\",\"dateModified\":\"2021-01-01T18:12:54+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/codedoneright.eu\/?page_id=1031#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codedoneright.eu\/?page_id=1031\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=1031#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codedoneright.eu\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\",\"item\":\"https:\/\/codedoneright.eu\/?page_id=1026\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Running script\",\"item\":\"https:\/\/codedoneright.eu\/?page_id=414\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Random Password Generator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codedoneright.eu\/#website\",\"url\":\"https:\/\/codedoneright.eu\/\",\"name\":\"Code Done Right!\",\"description\":\"Raspberry Pi server guides\",\"publisher\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codedoneright.eu\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\",\"name\":\"CodeDoneRight\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"contentUrl\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"width\":120,\"height\":120,\"caption\":\"CodeDoneRight\"},\"logo\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/codedoneright.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Random Password Generator &#8212; Code Done Right!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codedoneright.eu\/?page_id=1031","twitter_card":"summary_large_image","twitter_title":"Random Password Generator &#8212; Code Done Right!","twitter_description":"This is a random password generator script for Bash. It generates a password with 1 special character, 1 number, 1 lowercase letter, 1 uppercase letter and 9-16 additional characters from a combination of numbers, lowercase and uppercase letters. Note that&hellip;","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/codedoneright.eu\/?page_id=1031","url":"https:\/\/codedoneright.eu\/?page_id=1031","name":"Random Password Generator &#8212; Code Done Right!","isPartOf":{"@id":"https:\/\/codedoneright.eu\/#website"},"datePublished":"2020-05-10T02:39:57+00:00","dateModified":"2021-01-01T18:12:54+00:00","breadcrumb":{"@id":"https:\/\/codedoneright.eu\/?page_id=1031#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codedoneright.eu\/?page_id=1031"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/codedoneright.eu\/?page_id=1031#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codedoneright.eu\/"},{"@type":"ListItem","position":2,"name":"Linux","item":"https:\/\/codedoneright.eu\/?page_id=1026"},{"@type":"ListItem","position":3,"name":"Running script","item":"https:\/\/codedoneright.eu\/?page_id=414"},{"@type":"ListItem","position":4,"name":"Random Password Generator"}]},{"@type":"WebSite","@id":"https:\/\/codedoneright.eu\/#website","url":"https:\/\/codedoneright.eu\/","name":"Code Done Right!","description":"Raspberry Pi server guides","publisher":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codedoneright.eu\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568","name":"CodeDoneRight","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/","url":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","contentUrl":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","width":120,"height":120,"caption":"CodeDoneRight"},"logo":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/codedoneright.eu"]}]}},"_links":{"self":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1031"}],"collection":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1031"}],"version-history":[{"count":7,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1031\/revisions"}],"predecessor-version":[{"id":1429,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1031\/revisions\/1429"}],"up":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/414"}],"wp:attachment":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}