SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 54 of 54
  1. #51
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Lancaster University, UK
    2 Post(s)
    0 Thread(s)
    What if I used a raw binary hash?
    Hex and binary go hand in hand.

    Look at any decimal number - say 19382 for the sake of randomness.
    19382 in binary is:

    0100 1011 1011 0110

    Now, take every individual portion of 4 bits and turn it into a number:

    0100: 4
    1011: 11
    1011: 11
    0110: 6

    11 in Hex is B.
    So, the number is 4BB6.

    So basically, storing it in hex and binary would have the same result but with the latter would require more space presumably.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  2. #52
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Nottingham, UK
    1 Post(s)
    0 Thread(s)
    Well, the hex would take more space since you would store it as a varchar, with 8 bits per character, so twice as big as the binary version, but it is more convenient and easier to deal with.

  3. #53
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Sydney, NSW, Australia
    25 Post(s)
    1 Thread(s)
    The ideal setup once you decide on a key length is to work out how you can allow the key to be any possible value that fits the length rather than limiting it to just a subset of the values - ideally you want to be able to use characters that are not on the keyboard as well as those that are in order to increase the range of values as high as possible.

    An MD5 hash does give you the maximum possible values for the key but is only 16 characters long. SHA1 gives a 20 character key which is a slight improvement. Those are fairly short keys for any serious encryption though. The algorithms don't guarantee that you are going to get that even spread across all the possible values either unless you can somehow get people to use all the possible values in what they enter in to start with and if you can get them to do that then simply truncating keys that are too long would result in more values to test for in trying to break the key than using a hash would. If you are going to use a hash then perhaps a SHA512 with its 64 character key would be a reasonable choice since it at least produces a key length approaching that which you would want to use for this type of application.
    Stephen J Chapman, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #54
    SitePoint Member
    Join Date
    Jan 2009
    0 Post(s)
    0 Thread(s)
    Thanks for the tips.

Tags for this Thread


Posting Permissions

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