Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Programming > LotusScript > Generating Random Passwords with LotusScript and Formula Language
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Generating Random Passwords with LotusScript and Formula Language

Generate unique, random passwords based on any configurable criteria you wish.
Community articleGenerating Random Passwords with LotusScript and Formula Language
Added by ~Chloe Nimfoobergoden on January 30, 2018 | Version 1
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
Generate unique, random passwords based on any configurable criteria you wish.

I was recently asked if we could add a random password generator to one of our applications.  Generating inside the Notes client limited my language choices to LotusScript and Formula Language (for the most part).   Unfortunately LotusScript doesn't have many of the nice native features of Python or Javascript whereby you can reference individual characters in a string or do other standard string manipulations.  The approach I used was to create a Custom Sort for the @Sort() formula whereby each character was compared to the previous via a random number.  I hope you find this useful:

LotusScript Version

Dim uCaseLetters As Variant
Dim lCaseLetters As Variant
Dim digits As Variant
Dim symbols As Variant
Dim pw As String
Dim final As Variant

'Add in your mix of upper/lowercase letters, digits and valid symbols for your application 

  
uCaseLetters=Evaluate(|@Explode("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";",")|)
lCaseLetters = Evaluate(|@Explode("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";",")|)
digits=Evaluate(|@Explode("0,1,2,3,4,5,6,7,8,9";",")|)
symbols=Evaluate(|@Explode("@,#,$,%,^";",")|)

Randomize
For i = 1 To 2  'take 2 upper case letters
    pw = pw + uCaseLetters( Cint(  25  *Rnd+ 0   )) + ","
Next
    
    
For i = 1 To 2   'two digits
    pw = pw +  digits( Cint(  9  *Rnd+ 0   )) + ","
Next
    
For i = 1 To 2  'two symbols
    pw =  pw +  symbols( Cint(  4  *Rnd+ 0   ))+ ","
Next
    
    
For i = 1 To 4 `finally 4 lowercase letters
        pw= pw +    lCaseLetters( Cint(  25  *Rnd+ 0   ))+ ","
Next
    

`A total of 10 chars in our password but they are in order:  UCase, Digit, Symbol, LCase and need to be randomized

'Here we create a [Custom Sort] that uses the @Random Number generator to compare each character
final = Evaluate(|@Trim(@Implode(@Sort(@Explode("| + pw + |";",");[CustomSort];@If(@Random < @Random;@True;@False));""))|)
    

Msgbox final(0)
 

 

Formula Version

uppers:="A":"B":"C":"D":"E":"F":"G":"H":"I":"J":"K":"L":"M":"N":"O":"P":"Q":"R":"S":"T":"U":"V":"W":"X":"Y":"Z";
lowers:="a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z";
digits:="0":"1":"2":"3":"4":"5":"6":"7":"8":"9";
symbols:="%":"$":"^":"@":"!";
pw:="";

UC:=3;
DIGIT:=3;
SYMBOL:=3;
TOTAL:=12;

@For(i:=1;i pw:= pw :uppers[ @Integer(26 * @Random + 1)]
);

@For(i:=1;i pw:= pw : digits[ @Integer(10 * @Random + 1) ]
);


@For(i:=1;i pw:= pw: symbols[ @Integer(5 * @Random + 1)]
);

@For(i:=1;i<(TOTAL-UC-SYMBOL-DIGIT);i:=i+1;
pw:= pw : lowers[ @Integer(26 * @Random + 1)]
);

@SetField("randomPassword";@Trim(@Implode(@Sort(pw;[CustomSort];@If(@Random < @Random;@True;@False));"")))


  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (1)
collapsed Versions (1)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (1)Jan 30, 2018, 7:02:36 PM~Chloe Nimfoobergoden  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility