Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. password generation

password generation

Scheduled Pinned Locked Moved C#
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    quiteSmart
    wrote on last edited by
    #1

    Is there any code for automatic generation of a password. thnaks

    R V G S 4 Replies Last reply
    0
    • Q quiteSmart

      Is there any code for automatic generation of a password. thnaks

      R Offline
      R Offline
      Russell Jones
      wrote on last edited by
      #2

      I haven't seen one but it can't be that hard to create a function that takes a random number and returns a char based on the ascii values you allow. I think System.Convert.ToChar(int) is probably the function you need from the top of my head. Russell

      M 1 Reply Last reply
      0
      • R Russell Jones

        I haven't seen one but it can't be that hard to create a function that takes a random number and returns a char based on the ascii values you allow. I think System.Convert.ToChar(int) is probably the function you need from the top of my head. Russell

        M Offline
        M Offline
        Muammar
        wrote on last edited by
        #3

        arachnoid wrote:

        I think System.Convert.ToChar(int) is probably the function you need from the top of my head.

        Use it with Math.Random, but you'll end up having a senseless password!!


        All generalizations are wrong, including this one! (\ /) (O.o) (><)

        R 1 Reply Last reply
        0
        • M Muammar

          arachnoid wrote:

          I think System.Convert.ToChar(int) is probably the function you need from the top of my head.

          Use it with Math.Random, but you'll end up having a senseless password!!


          All generalizations are wrong, including this one! (\ /) (O.o) (><)

          R Offline
          R Offline
          Russell Jones
          wrote on last edited by
          #4

          i was thinking that that was the critical function rather than using that as the whole algorithm. Then create a wrapper that creates a random number between 0 and 61 and returns an lcase, a ucase or a number with equal probability Russ

          Q 1 Reply Last reply
          0
          • R Russell Jones

            i was thinking that that was the critical function rather than using that as the whole algorithm. Then create a wrapper that creates a random number between 0 and 61 and returns an lcase, a ucase or a number with equal probability Russ

            Q Offline
            Q Offline
            quiteSmart
            wrote on last edited by
            #5

            It is like an automatic generation for an activation code. Maybe my description as a password was some how wronge

            R 1 Reply Last reply
            0
            • Q quiteSmart

              It is like an automatic generation for an activation code. Maybe my description as a password was some how wronge

              R Offline
              R Offline
              Russell Jones
              wrote on last edited by
              #6

              use math.random to create a nuber between 0 and 61 use a switch statement for 0 to 25, 26 to 51, 52 to 61 convert the numbers to letters or numbers using system.convert.tochar(int) and these values ^ loop to create a pwd of required length HTH Russ

              1 Reply Last reply
              0
              • Q quiteSmart

                Is there any code for automatic generation of a password. thnaks

                V Offline
                V Offline
                V 0
                wrote on last edited by
                #7

                Create a char array with all the 'allowed characters' Call up a random number between 0 and the length of that array for the amount of characters the password should contain.

                V. I found a living worth working for, but haven't found work worth living for.

                1 Reply Last reply
                0
                • Q quiteSmart

                  Is there any code for automatic generation of a password. thnaks

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #8

                  www.guffa.com: Random password[^]

                  --- Year happy = new Year(2007);

                  1 Reply Last reply
                  0
                  • Q quiteSmart

                    Is there any code for automatic generation of a password. thnaks

                    S Offline
                    S Offline
                    szukuro
                    wrote on last edited by
                    #9

                    I think the biggest problem a lot of password generating programs have is that they don't guarantee a strong password. While choosing random characters from a set of predifined values might get you very diversive password, it doesn't mean it always will. So despite using long password, you could still end up with weak ones like 'ifdhgkfsd'. There should be some code to check, if teh generated password meets some special requirements, and possibly do some adjustments. A good example for this is the built-in membership provider for ASP.NET 2.0, which requires you to have at least one non-alphanumerical character in your password. Then again it's not a generator tool, it just checks a given password. I don't mean to stay you need these precautions in every case, however I do mean you should find (or possible write) code that allows usage of similiar features. For example: public string GetPassword(int length, int minUppercaseLetterCount, int minNumberCount, int minNonAlphanumericalCount) { //your code here :) } Obviously, for simple passwords you would use it like GetPassword(5, 0, 0, 0). And if you ever need strong passwords you can still reuse this function. I think this smells like an article :). Someone should write it. Or maybe I will :-D.

                    Q 1 Reply Last reply
                    0
                    • S szukuro

                      I think the biggest problem a lot of password generating programs have is that they don't guarantee a strong password. While choosing random characters from a set of predifined values might get you very diversive password, it doesn't mean it always will. So despite using long password, you could still end up with weak ones like 'ifdhgkfsd'. There should be some code to check, if teh generated password meets some special requirements, and possibly do some adjustments. A good example for this is the built-in membership provider for ASP.NET 2.0, which requires you to have at least one non-alphanumerical character in your password. Then again it's not a generator tool, it just checks a given password. I don't mean to stay you need these precautions in every case, however I do mean you should find (or possible write) code that allows usage of similiar features. For example: public string GetPassword(int length, int minUppercaseLetterCount, int minNumberCount, int minNonAlphanumericalCount) { //your code here :) } Obviously, for simple passwords you would use it like GetPassword(5, 0, 0, 0). And if you ever need strong passwords you can still reuse this function. I think this smells like an article :). Someone should write it. Or maybe I will :-D.

                      Q Offline
                      Q Offline
                      quiteSmart
                      wrote on last edited by
                      #10

                      it smells like an article but you should add to it some code ;)

                      szukuro wrote:

                      I think the biggest problem a lot of password generating programs have is that they don't guarantee a strong password.

                      i thought about this problem. SO i took the function that GUFFA provided and i am trying to implement it in a way to force it to generate some strong password with at least 2 digits in it.

                      S 1 Reply Last reply
                      0
                      • Q quiteSmart

                        it smells like an article but you should add to it some code ;)

                        szukuro wrote:

                        I think the biggest problem a lot of password generating programs have is that they don't guarantee a strong password.

                        i thought about this problem. SO i took the function that GUFFA provided and i am trying to implement it in a way to force it to generate some strong password with at least 2 digits in it.

                        S Offline
                        S Offline
                        szukuro
                        wrote on last edited by
                        #11

                        Obviously by writing an article I also meant writing the code, since the article itself would be pretty much the code itself, with some explanation :).

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups