Example of storing encrypted password in database and verifying against encrypted password
- Clone this repository.
- Open IntelliJ -> Open -> Choose the project you just cloned (The root path must contain the pom.xml!) -> The IntelliJ will load automatically.
- Go to UpdateSecurePassword.java, make sure to change your mysql username and password.
- Run UpdateSecurePassword.java on your local machine, it will update the passwords in your existing moviedb customers table from plain text to encrypted string.
- Go to VerifyPassword.java, also change your mysql username and password. This program will verify if the email and password are valid.
To run it on AWS under command line:
- Clone this repository using.
cd cs122b-project3-encryption-example- change your mysql username and password in UpdateSecurePassword.java and VerifyPassword.java
mvn compile- Have a backup of the "customers" table, run the following:
create table customers_backup(id integer auto_increment primary key,firstName varchar(50) not null,lastName varchar(50) not null,ccId varchar(20) not null,address varchar(200) not null,email varchar(50) not null,password varchar(20) not null,foreign key(ccId) references creditcards(id));insert into customers_backup select * from customers; - to run
UpdateSecurePassword:mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass="UpdateSecurePassword" - to run
VerifyPassword:mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass="VerifyPassword" - When execute java program using maven in command line, if the program doesn't exist after it finishes, you can just kill it.
- To recover the data in the "customers" table, run the following:
update customers C1 set password = (select password from customers_backup C2 where C2.id = C1.id);