Click here to Skip to main content
15,887,821 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i made a system to encrypt the data in database using AES-128. after the AES code applied, the data didnt insert into my system and database. can someone help me ? this for my final year project. i dont know what to do anymore. if i fail this subject, i might quit my bachelor degree. no one can help me, even my friends. i dont know what to do anymore. What I have tried:

What I have tried:

SQL
$sql="INSERT INTO aes.employee (
    emp_id,
    name,
    ic,
    gender,
    email,
    phoneNo,
    kwsp,
    salary,
    dept
) 
VALUES (
    null,
    aes_encrypt('$emp_id','33433'),
    aes_encrypt('$name',''33433),
    aes_encrypt('$ic','33433'),
    aes_encrpyt('$gender',''33433'),
    aes_encrpyt('$email','33433'),
    aes_encrypt('$phoneNo','33433'),
    aes_encrypt('$kwsp','33433'),
    aes_encrypt('$salary','33433'),
    aes_encrypt('$dept','33433')
)";
Posted
Updated 10-Jul-21 12:53pm
v2
Comments
Richard Deeming 12-Jul-21 6:28am    
NB: Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

PHP: SQL Injection - Manual[^]

1 solution

Well, first of all, you listed 9 columns you said you were going to have values for, but then you listed 10 values to pout into those columns. Those two lists much match and they don't!

Next, if your emp_id is an AUTOINCREMENT, or equivalent, you do NOT put it in the parameter list nor do you supply it with a NULL value.

Next, AFAIK, the encrypt function only works on strings, so if you're supplying numbers, like salary, it won't work.

If your emp_id column is an identity column, you cannot encrypt it.

But the real question is why are you trying to encrypt everything?
 
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