Professional Web Applications Themes

Varchar Minimum Character Length - MySQL

Hello, I'm new to MySQL and am currently creating a small database driven website. My question is :- In the 'users' table the password field is set out with 'VARCHAR(20) NOT NULL' to give me a maximum length of 20 characters, how can I specify a minimum password length of say 5 characters? - Is this to be done in table creation or by some sort of input mask on the 'register account' page?...

  1. #1

    Default Varchar Minimum Character Length

    Hello, I'm new to MySQL and am currently creating a small database driven
    website. My question is :- In the 'users' table the password field is set
    out with 'VARCHAR(20) NOT NULL' to give me a maximum length of 20
    characters, how can I specify a minimum password length of say 5
    characters? - Is this to be done in table creation or by some sort of input
    mask on the 'register account' page?


    Katash Guest

  2. #2

    Default Re: Varchar Minimum Character Length

    Katash wrote:
    > Hello, I'm new to MySQL and am currently creating a small database driven
    > website. My question is :- In the 'users' table the password field is set
    > out with 'VARCHAR(20) NOT NULL' to give me a maximum length of 20
    > characters, how can I specify a minimum password length of say 5
    > characters? - Is this to be done in table creation or by some sort of input
    > mask on the 'register account' page?
    The string in that column is not the password. It's an encrypted form
    of the password, using MySQL's PASSWORD() function. Like many hashing
    functions (e.g. MD5 or SHA-1), this function outputs a string of fixed
    length, regardless of the length of the input.

    See [url]http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html[/url] for
    more information.

    (NB: note that the docs recommend that you do _not_ use the PASSWORD
    function for your applications, use MD5 or SHA-1 instead.)

    Instead of letting the database enforce password rules, you should
    enforce rules about password length in your application, as you accept
    the user's input, and before you encrypt and store the password. This
    also gives you the opportunity to yze the password for other
    purposes: it shouldn't be in the dictionary, should contain both letters
    and digits, etc.

    For what it's worth, I never use the MySQL 'users' table to manage users
    and passwords for a web site. I create an accounts table in the
    database for my application, and use that for the web app to
    authenticate against. When connecting to MySQL, the web app always uses
    a single MySQL user, regardless of who is using the web app.

    In my accounts table, I use MD5 or SHA-1 as a one-way encryption to
    store the users' passwords. When they later log in and give their
    password, encrypt the string they input and compare that against what's
    stored in the database. That way you never store their password in
    clear text.

    Regards,
    Bill K.
    Bill Karwin Guest

Similar Threads

  1. Length cannot be less than zero. Parameter name: length
    By ctk70 in forum ASP.NET Security
    Replies: 3
    Last Post: November 14th, 02:34 PM
  2. Replies: 1
    Last Post: February 16th, 01:12 PM
  3. Increasing the length of a varchar domain
    By Rich Doughty in forum PostgreSQL / PGSQL
    Replies: 0
    Last Post: January 31st, 12:26 PM
  4. InDesign ME Character Problem! Character-Change by Printing or saving *.PS!
    By gree@adobeforums.com in forum Adobe Indesign Windows
    Replies: 48
    Last Post: May 25th, 02:07 PM
  5. How to get length of string? length() problems
    By Mitchua in forum PERL Modules
    Replies: 5
    Last Post: July 17th, 12:08 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139