How to create a random password in ASP.NET

Here is a quick bit of code to create a random string

share on facebook share on twitter share on google share on digg share on linked in share on stumble upon

Here is a quick bit of code to create a random string, it doesn't have to be a password but we think you get the idea

Public Shared Function CreateRandomPassword(ByVal PasswordLength As Integer) As String

        Dim _allowedChars As String = "abcdefghijkmnopqrstuvwxy
zABCDEFGHJKLMNOPQRSTUVWXYZ0123456789" Dim randNum As New Random() Dim chars(PasswordLength - 1) As Char Dim allowedCharCount As Integer = _allowedChars.Length For i As Integer = 0 To PasswordLength - 1 chars(i) = _allowedChars.Chars(CInt(Fix((_allowedChars.Length)
* randNum.NextDouble()))) Next i Return New String(chars) End Function

How to create a random password in ASP.NET

Posted in Coding by on 05 January 2014

Related Posts

Best Practice Guide - Meta Descriptions
BEST PRACTICE GUIDE - META DESCRIPTIONS
What Are CSS Shapes?
WHAT ARE CSS SHAPES?
Erm...What is CAPTCHA?
ERM...WHAT IS CAPTCHA?
How To Create A Link To A Phone Number In HTML
HOW TO CREATE A LINK TO A PHONE NUMBER IN HTML
Special HTML Characters
SPECIAL HTML CHARACTERS
Best Practice - Caching Files Using ASP Dot Net
BEST PRACTICE - CACHING FILES USING ASP DOT NET

Fresh From Twitter...

Join the conversation on Twitter @pebbleltd
for all the latest news on web design, ecommerce and search engine marketing with one of the leading web design agencies in the uk

  • Pebble (Peterborough)

    26 Tesla Court
    Innovation Way
    Peterborough
    PE2 6FL

    Tel: 01733 902070

    View On Map

  • Pebble (Kings Langley)

    The Old Chapel
    69 Primrose Hill
    Kings Langley
    WD4 8HX

    Tel: 01442 505878

    View On Map

Pebble Ltd is registered in England & Wales: 06257777 and registered for VAT No: 993 3500 06

Pebble Ltd is Data Protection registered ZA122783

How to create a random password in ASP.NET How to create a random password in ASP.NET Here is a quick bit of code to create a random string

Here is a quick bit of code to create a random string, it doesn't have to be a password but we think you get the idea

Public Shared Function CreateRandomPassword(ByVal PasswordLength As Integer) As String

        Dim _allowedChars As String = "abcdefghijkmnopqrstuvwxy
zABCDEFGHJKLMNOPQRSTUVWXYZ0123456789" Dim randNum As New Random() Dim chars(PasswordLength - 1) As Char Dim allowedCharCount As Integer = _allowedChars.Length For i As Integer = 0 To PasswordLength - 1 chars(i) = _allowedChars.Chars(CInt(Fix((_allowedChars.Length)
* randNum.NextDouble()))) Next i Return New String(chars) End Function

Contact Pebble

  • Pebble Ltd (Peterborough)
    26 Tesla Court
    Innovation Way
    Peterborough
    PE2 6FL
    Tel: 01733 902070
  • Pebble Ltd (Kings Langley)
    The Old Chapel
    69 Primrose Hill
    Kings Langley
    WD4 8HX
    Tel: 01442 505878