Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3863
  • Last Modified:

MD5 in oracle

hi
a very small question that , i am getting error if i write like this, i want to create login/logout for my web interface using PHP, i am using oracle

insert into users(user_id, username, password) values(1,'test', md5('test'));

can any one tell be how should i write .
As i know The md5() function is built into PHP, and will convert your password into a 32 character string. This is one good method for encrypting password information
 
desc users

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 USER_ID                                   NOT NULL NUMBER(10)
 USERNAME                                  NOT NULL VARCHAR2(20)
 PASSWORD                                  NOT NULL VARCHAR2(32)

thx
0
manish14
Asked:
manish14
  • 3
  • 2
1 Solution
 
ThGCommented:

i don't have oracle here to test but it should work. First, report the error you are getting, second try:
select md5('test');

if that shouldn't work, you can still insert "values (1,'test','" . md5("test") . "');
0
 
manish14Author Commented:
error is ORA-00904: "MD5": invalid identifier

i tried your solution, i am getting password field like this, is it correct way to encrypt the password

 select * from users;

   USER_ID USERNAME             PASSWORD
---------- -------------------- --------------------------------
         1 test                 " . md5("test") . "
0
 
ThGCommented:
what's that?! you inserted the raw string!
you need proper escaping.. please note that my md5() was a PHP function, not an ORACLE function like yours (that actually doesn't exist..)

Please keep quotes consistent:

$query = "insert into users(user_id, username, password) values(1,'test', " . md5("test") . ");";
0
 
ThGCommented:
whops.. this is the correct one:

$query = "insert into users(user_id, username, password) values(1,'test', '" . md5("test") . "');";
0
 
manish14Author Commented:
md5  didn't work in insert statement for me so i put md5 in the begning , like this i am inserting already encrypted value.

thx for your comment
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now