Storing hexadecimal values as binary in MySQL

后端 未结 6 937
情话喂你
情话喂你 2020-12-15 08:42

I was thinking about how I\'m storing passwords in my database : appropriately salted SHA1 strings in a CHAR(40) field. However, since the character data in there is actuall

6条回答
  •  一向
    一向 (楼主)
    2020-12-15 09:16

    If you want a easy way to store binary in sql... you can convert to hex before. Check out this page: http://kekoav.com/blog/36-computers/58-uuids-as-primary-keys-in-mysql.html

    Convert to hex, take off the "-" and put "0x" in front of the string. Mysql will understand as a byte content.

    Example: INSERT INTO users SET password=0x1e8ef774581c102cbcfef1ab81872213

提交回复
热议问题