Search code examples
mysqlhashsha

MySQL SHA-256 Double Hashing Fails Truncating Data


I am trying to do the following following MYSQL script:

INSERT INTO `loop`.`User`
(`userID`,
`firstName`,
`lastName`,
`email`,
`password`,
`userName`,
`bio`,
`spamCount`)
VALUES
('gZvTtlPtjGRqeMBaLji3HxoKB5EZCsNL',
'Sarah',
'Joane',
'[email protected]',
 SHA2(SHA2('test0',256)+'gZvTtlPtjGRqeMBaLji3HxoKB5EZCsNL', 256),
'[email protected]',
'My....e',
0)

The problem is the I am getting the error:

1 row(s) affected, 1 warning(s): 1292 Truncated incorrect DOUBLE value: 'xRgkwBC9f0MXTgpb5nrNpRevaMYRlKpH' 0.00045 sec

I am confused as the row does not even have any double values in it. Is the double hashing somehow causing this?


Solution

  • To concatenate strings, you want to use CONCAT(string1, string1), rather than the + operator.