Excel VB | random password generator
There are a few of way I like to create random passwords usually from a Filemaker server based database, for more security, but here is an Excel visual basic equivalent of what I use:
Random Password Generator
This code below generates passwords completely randomly.
Public Function RndPass(Length As Integer, Optional Lower As Boolean) As String
Dim Max As Integer
Dim Min As IntegerDim RndPassLoop As String
Max = 126
Min = 48Randomize Timer
If Length < 8 Then
Length = 8
End IfFor i = 1 To Length
RndPassLoop = RndPassLoop & Chr(Int((Max - Min + 1) * Rnd + Min))
Next iIf Lower = False Then
RndPass = RndPassLoop
Else
RndPass = StrConv(RndPassLoop, vbLowerCase)
End IfEnd Function
‘add this code to a vb module
’syntax is RndPass(Length of password, True (lowercase) / Empty or False (both upper and lower)
‘RndPass(20,1) = 20 characters lower case
Random Letter Generator
This code below will generator code for a random letter or number based string.
Public Function RndPassP(Phrase As String) As String
Dim Max As Integer
Dim Min As IntegerDim RndPassLoop As String
If Len(Phrase) < 12 Then
RndPassP = “Phrase too short - please choose something longer”
Exit Function
End IfIf subStringCount(Phrase, “a”) + _
subStringCount(Phrase, “c”) + _
subStringCount(Phrase, “e”) + _
subStringCount(Phrase, “i”) + _
subStringCount(Phrase, “o”) + _
subStringCount(Phrase, “s”) + _
subStringCount(Phrase, “u”) + _
subStringCount(Phrase, “r”) < 4 ThenRndPassP = “Phrase does not include enough key letters - please choose another”
Exit Function
End IfPhrase = StrConv(Phrase, vbLowerCase)
Randomize Timer
RndPassLoop = Replace(Phrase, “a”, “@”)
Phrase = Replace(RndPassLoop, “b”, “8″)
RndPassLoop = Replace(Phrase, “e”, “3″)
Phrase = Replace(RndPassLoop, “i”, “!”)
RndPassLoop = Replace(Phrase, “o”, “0″)
Phrase = Replace(RndPassLoop, “s”, “$”)
RndPassLoop = Replace(Phrase, ” “, “”)
Phrase = Replace(RndPassLoop, “u”, ” * “)
RndPassLoop = Replace(Phrase, “r”, “£”)
Phrase = Replace(RndPassLoop, “M”, “M”)
RndPassLoop = Replace(Phrase, “N”, “N”)
Phrase = Replace(RndPassLoop, “T”, “T”)
RndPassLoop = Replace(Phrase, “X”, “X”)
Phrase = Replace(RndPassLoop, “G”, “G”)Phrase = RndPassLoop & “:)”"”
RndPassP = Phrase
End Function
Function subStringCount(longString As String, subString As String) As Double
subStringCount = Len(longString) _
- Len(Application.Substitute(longString, subString, vbNullChar))
End Function‘add this code to a vb module
’syntax is ‘RndPassP(string):
‘RndPassP (”I work in Property Finance”)
Let me know what you think about these and what sort of password system you use?
Follow my updates on Twitter here
- Just found out about this designer Pedro Vilas-Boas yesterday - his ten_pt work blew me away: http://www.vilaz.tv/. (12 hrs ago)
About
You’re currently reading “Excel VB | random password generator”.
- Published:
- Monday, August 18th, 2008
- Author:
- Simon Page
- Category:
- Excel
- Tags:
- downloads, excel 2003, excel 2007, free, security, vb, vba, visual basic
Related Posts
Categories
- Artwork (58)
- Design Inspiration (23)
- Design Resources (6)
- Excel (12)
- Filemaker (5)
- Gadgets (26)
- Music (3)
- Photography (3)
- Photoshop (1)
- Press (3)
- Random (5)
- Software (4)
- Video Gaming (15)
Featured Posts
- 20 of the Best Amazing Photoshop Tutorials
- Creative Movie Poster Inspiration
- December 09: Graphic Designs, Illustrations and looking back at 2009
- Design Inspiration | typography posters
- Fun with Circles poster designs
- Inspiring Gallery of Video Game Concept Art
- International Year of Astronomy 2009 Posters
- Resources of Creative Design Inspiration
- Rolet Design Concept
- Top 10 Gadgets for 2009
- Top Christmas Electronics
- Tron Legacy Movie Poster






6 Comments
Jump to comment form | comments rss | trackback uri