Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all

now i was having a problem with UTF8 and my program and the sol was to use ODBC 5.1 instead of 3.5 but now i found new problem

when i insert using the following sql command

SQL
INSERT INTO users
(UserName, PassWord)
VALUES (?, SHA1(?))


i get ODBC 5.1 error memory allocation error !! although it was working so fine in ODBC 3.5 and when i just remove SHA1 , it worked again ??

so what should i do?
i tried many other fun. like MD5 , encrypt ...... all not working
Posted
Updated 10-May-11 6:52am
v3
Comments
Karthik. A 10-May-11 12:52pm    
Formatted the question.

First, you should be hashing the password in your code, not in the SQL. Why? Because you're transmitting the password "in the clear" between your code and the SQL server. A man-in-the-middle attack can watch the SQL request fly by and yank out the account id and password.

You already found out about the second reason why you don't do this: Compatibility. The method you chose to access the database is not tolerate of upgrades. Also, the backing database may not support the hashing function you want (you are using ODBC for generic access to various database engines, correct?)
 
Share this answer
 
v2
Comments
Marc A. Brown 10-May-11 13:29pm    
Great answer.
Skip ODBC driver for MySql and download MySql Connector/Net[^] native C# driver.

And use MySqlParameter for the job. Do as Dave suggests. Do hashing before INSERT statement.
 
Share this answer
 
odbc ver. 3 support sha but ver. 5 makes such problem
 
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