random password

by 16 replies
18
I need to know where I can find a code
that will give me a random password to
people who sign up for my product via
an email.

Can anyone help?

Thanks
#programming #password #random
  • Hi Mobiousman,

    I'll assume you're using PHP. I've used the function in the following URL before:

    PHP random password generator

    It's quite straightforward and it allows you to specify the length and strength.

    Hope that helps.
  • do you also need the php function to send the email besides generating the random password?
    • [1] reply
    • Yes I would need that.
      Can I program a random password in asp format.
      Where would be a good source to grenerate
      such passwords.

      thanks
  • So, are you saying that you need ASP code that will generate a password and send that password to the people who sign up for your product?
    • [1] reply
    • Not necessarily I just want to know where I can go to generate my own random password with out costing an arm and leg.

      I would prefer if there were some software (preferable free) that I could do this myself.

      thanks
  • More questions then... lol

    A free software, in ASP? That will generate random passwords..? hmm...

    Are you planning on running this software automatically whenever someone signs up? Or is it something you do manually?

    If it's automatically, then you simply need to check out the PHP code that osegoly linked to, rewrite it into ASP and then your done.

    If you do it manually, you might wanna have a look at: Online Password Generator or just google for "free password generator"
    • [1] reply
    • What about using Javascript password Generator

      function GeneratePassword() {

      if (parseInt(navigator.appVersion) <= 3) {
      alert("Sorry this only works in 4.0+ browsers");
      return true;
      }

      var length=8;
      var sPassword = "";

      var noPunction = true;
      var randomLength = false;

      if (randomLength) {
      length = Math.random();

      length = parseInt(length * 100);
      length = (length % 7) + 6
      }


      for (i=0; i < length; i++) {

      numI = getRandomNum();
      if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }

      sPassword = sPassword + String.fromCharCode(numI);
      }

      document.getElementById("txtLoginPassword").value = sPassword //add to password input text
      alert("Your new password is " + sPassword +"");
      return true;
      }

      function getRandomNum() {

      // between 0 - 1
      var rndNum = Math.random()

      // rndNum from 0 - 1000
      rndNum = parseInt(rndNum * 1000);

      // rndNum from 33 - 127
      rndNum = (rndNum % 94) + 33;

      return rndNum;
      }

      function checkPunc(num) {

      if ((num >=33) && (num <=47)) { return true; }
      if ((num >=58) && (num <=64)) { return true; }
      if ((num >=91) && (num <=96)) { return true; }
      if ((num >=123) && (num <=126)) { return true; }

      return false;
      }

      you just call GeneratePassword function to generate the password before post back to server. This can be use in any kind of server side script either php or asp or .net. You might need to rewrite a little bit on Javascript function to suit your need though.
  • I think working on with a server side script to generate random password like php is the best approach to this.
  • I quickly knocked up a php password generator for you:

    <?=substr(base64_encode(time().time()-1049212),rand(6,10),rand(8,14))?>
    • [2] replies
    • Or if you just want to generate manually and keep for future reference . use "Password Safe".

      its free and you can download here "passwordsafe.sourceforge.net"
    • <?=substr(base64_encode(time().time()-1049212),rand(6,10),rand(8,14))?>[/QUOTE]

      Can I use this script in an email I send to my prospects?

      thanks
      • [1] reply
  • Why not just set a separate field in the database with a "token", which they get in the confirmation email, then they get to set their password. I say this because it's easier to test if the password field is blank or a token is present when values are null, rather than a random password.

    People also hate random passwords they can't change ...
    • [1] reply
    • Ok that is great idea but I want this password
      to be used only once and then it can't be used
      again.
      Is this possible?

      Thanks for your help.
  • Yes it is possible.

    Any more questions?

    Seriously though, what you need is to keep track of when the user logs in. The first time the user logs in, you mark the password as "used". Whenever someone tries to login, you check if the password has been used or not.

    Why don't you post all the details about the full requirements you have, with a list of all the features you want in your login/password/email-script and it will be a lot easier for us to help you. Thanks in advance!
    • [1] reply
    • Thanks for being so gracious with your know-how.
      This is what I need:
      (BTW - Every site I have uses a self-hosted Wordpress install. So whatever scripts I use must be compliant with Wordpress.

      Before my client first gains access to our private on-line seminar room she needs to fill out a registration form.
      The system will then generate a 4-digit password and email it out.
      When she finishes her session in the seminar room (about a full day) I don't want her, or anyone else for that matter, to be able to use that password to get into the on-line seminar work area ever again. (That's because they only have one shot at completing the e-seminar correctly. No coming back in later.)

      In other words I need the ability to de-activate that password manually.

      How can this be done?

      Thanks a heap for all your help. You guys are amazing!

      ...David
  • Banned
    [DELETED]
    • [ 1 ] Thanks

Next Topics on Trending Feed