The WTF effect

Discussion in 'Programming General' started by Dr. James, Sep 27, 2010.

The WTF effect
  1. Unread #1 - Sep 27, 2010 at 8:05 AM
  2. Dr. James
    Joined:
    Sep 17, 2010
    Posts:
    120
    Referrals:
    0
    Sythe Gold:
    0

    Dr. James Active Member
    $5 USD Donor New

    The WTF effect

    Lol, don't worry. delete this ;\
    I was just wondering why when you md5(NULL) it is different to md5(0) or NULL+NULL, when they work out the same without md5ing...
     
  3. Unread #2 - Sep 29, 2010 at 7:48 PM
  4. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    The WTF effect

    md5(0) and md5(NULL+NULL) return the same thing because when using the + operator on a NULL value, the interpreter (probably php in your case) turns that NULL into a 0. 0+0=0.

    The reason md5(NULL) doesn't do the same thing is because NULL is an empty string (also still assuming it's php). md5 still returns hashes even on an empty string (null) . If you cast a null to an int, you'll get the previous value, of md5(0).
     
  5. Unread #3 - Sep 29, 2010 at 11:36 PM
  6. Dr. James
    Joined:
    Sep 17, 2010
    Posts:
    120
    Referrals:
    0
    Sythe Gold:
    0

    Dr. James Active Member
    $5 USD Donor New

    The WTF effect

    Makes much sense. I asked a 'supposed' security expert and he just laughed at me lol.
     
< Help Willing to Pay | [Tut] How to use a Progress Bar. (No timers.) [Tut] >

Users viewing this thread
1 guest


 
 
Adblock breaks this site