Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--- Remove Salt and Hash value Columns from Users table --->
- <cfquery name="DeleteSaltColumn" datasource="database">
- ALTER TABLE users DROP COLUMN Salt;
- </cfquery>
- <cfquery name="DeleteHashedColumn" datasource="database">
- ALTER TABLE users DROP COLUMN Hashed;
- </cfquery>
- <!--- Add two new columns to Users table for Salt and Hash values --->
- <cfquery name="AddSaltColumn" datasource="database">
- ALTER TABLE useusersrs_copy ADD Salt BINARY(88);
- </cfquery>
- <cfquery name="AddHashedColumn" datasource="database">
- ALTER TABLE users ADD Hashed BINARY(128);
- </cfquery>
- <!--- Get all records from the User table --->
- <cfquery name="RetrieveRecords" datasource="database">
- SELECT *
- FROM users
- </cfquery>
- <cfloop query="RetrieveRecords">
- <cfset form.UserName = RetrieveRecords.UserName>
- <cfset form.UserPassword = RetrieveRecords.UserPassword>
- <cfset form.Salt = GenerateSecretKey("AES", 512) >
- <cfset form.Hashed = Hash(form.Salt & form.UserPassword, "SHA-512")>
- <cfquery name="UpdateRecord" datasource="database">
- UPDATE users
- SET Salt = '#form.Salt#', Hashed = '#form.Hashed#'
- WHERE UserName = '#form.UserName#'
- <!--- UserName field is the Primary Key in this database --->
- </cfquery>
- </cfloop>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement