Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I have my password column with varchar(50) datatype. now i have created a new column NewPassword binary(16).
I want to convert password varchar data to binary(16) format in NewPassword column.

How can i do it?

Thanks.
Posted

1 solution

We can't answer that.

Firstly, there is no way to pack 50 characters into 16 bytes: even if you only had A-Z and a couple of other characters in there, you couldn't guarantee to "squash" it down: 26 characters (call it 32 to make the math easy) needs 50 * 5 bits = 250 and 16 bytes only has 128 bits.

Secondly, the only way you will get it in there is to hash it - and since we have no idea what hashing algorithm you are thinking of useing, we can't tell you how to do it in SQL - I wouldn't even if I could, personally as I'd want to use the "real" code to make sure it worked when I checked them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900