# vCO Create Random Password Action

Need to create a random password in vCO, maybe to be able to create a user account in Active Directory or elsewhere? I created an action for this task which can be reused in any workflow. The code for this is below.

There’s one input passwordLength to determine how long you want the password to be. The action can be used in a workflow like so: Alternatively, you can download the action to import into your own vCO install from my vCOModules repository on GitHub, where I’m beginning to store modules of generic actions I use. Only a few items there at the minute, but plenty to follow……

[code language=“javascript”]

throw “Parameter PasswordLength needs to be at least 5”; }

var pickNumber = passwordLength - 4

function shuffle(string) { var parts = string.split(’’); for (var i = parts.length; i > 0;) { var random = parseInt(Math.random() * i); var temp = parts[–i]; parts[i] = parts[random]; parts[random] = temp; } return parts.join(’’); }

var lowercase = ‘abcdefghijklmnopqrstuvwxyz’; var uppercase = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’; var numbers = ‘0123456789’; var special = ‘!?£\$@’; var all = lowercase + uppercase + numbers + special;

var c1 = lowercase.charAt(Math.floor(Math.random() * lowercase.length)); var c2 = uppercase.charAt(Math.floor(Math.random() * uppercase.length)); var c3 = numbers.charAt(Math.floor(Math.random() * numbers.length)); var c4 = special.charAt(Math.floor(Math.random() * special.length)); var c5 = ‘’;

for( var i=0; i < pickNumber; i++ ){ c5 += all.charAt(Math.floor(Math.random() * all.length)); }

var c6 = c1 + c2 + c3 + c4 + c5; password = shuffle(c6);
{"ft_lang_label":"__label__en","ft_lang_prob":0.53783154,"math_prob":0.98518544,"size":1728,"snap":"2023-40-2023-50","text_gpt3_token_len":426,"char_repetition_ratio":0.15313224,"word_repetition_ratio":0.0,"special_character_ratio":0.28993055,"punctuation_ratio":0.190625,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96574926,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-01T19:11:40Z\",\"WARC-Record-ID\":\"<urn:uuid:c9838b9d-3e28-4e7c-a437-40b673615043>\",\"Content-Length\":\"6794\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f0b5a3a8-0c16-47f6-8b0e-a8da05b74305>\",\"WARC-Concurrent-To\":\"<urn:uuid:3d861c49-4680-4f88-813c-cd0289ae1c65>\",\"WARC-IP-Address\":\"172.67.202.67\",\"WARC-Target-URI\":\"https://www.jonathanmedd.net/2014/06/vco-create-random-password-action.html\",\"WARC-Payload-Digest\":\"sha1:I54ZCJE7YXVXLTXUGPJ3MVIPNZLYGXZL\",\"WARC-Block-Digest\":\"sha1:6HYIGITW36V4WWCNLKB35LZG4VK3C4GW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510924.74_warc_CC-MAIN-20231001173415-20231001203415-00076.warc.gz\"}"}