Convert javascript value to binary to be placed into mysql -
i have column in mysql
table of type binary
(password
). within object:
{ password: request.password };
each value in object string
. how convert value password
binary placed mysql row?
+------------+--------------+------+-----+-------------------+-------+ | field | type | null | key | default | | +------------+--------------+------+-----+-------------------+-------+ | password | binary(16) | no | pri | | | +------------+--------------+------+-----+-------------------+-------+
use
var password = "abc"; var result = ""; function converttobinarystring(decimal){ return (decimal >>> 0).tostring(2); } password.split('').foreach(function(char){ result += converttobinarystring(char.charcodeat(0)) }) console.log(result) // 110000111000101100011
Comments
Post a Comment