Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <!--- Remove Salt and Hash value Columns from Users table --->
  2.  
  3. <cfquery name="DeleteSaltColumn" datasource="database">
  4. ALTER TABLE users DROP COLUMN Salt;
  5. </cfquery>
  6.  
  7. <cfquery name="DeleteHashedColumn" datasource="database">
  8. ALTER TABLE users DROP COLUMN Hashed;
  9. </cfquery>
  10.  
  11. <!--- Add two new columns to Users table for Salt and Hash values --->
  12.  
  13. <cfquery name="AddSaltColumn" datasource="database">
  14. ALTER TABLE useusersrs_copy ADD Salt BINARY(88);
  15. </cfquery>
  16.  
  17. <cfquery name="AddHashedColumn" datasource="database">
  18. ALTER TABLE users ADD Hashed BINARY(128);
  19. </cfquery>
  20.  
  21. <!--- Get all records from the User table --->
  22.  
  23. <cfquery name="RetrieveRecords" datasource="database">
  24. SELECT *
  25. FROM users
  26. </cfquery>
  27.  
  28. <cfloop query="RetrieveRecords">
  29. <cfset form.UserName = RetrieveRecords.UserName>
  30. <cfset form.UserPassword = RetrieveRecords.UserPassword>
  31. <cfset form.Salt = GenerateSecretKey("AES", 512) >
  32. <cfset form.Hashed = Hash(form.Salt & form.UserPassword, "SHA-512")>
  33.  
  34. <cfquery name="UpdateRecord" datasource="database">
  35. UPDATE users
  36. SET Salt = '#form.Salt#', Hashed = '#form.Hashed#'
  37. WHERE UserName = '#form.UserName#'
  38. <!--- UserName field is the Primary Key in this database --->
  39. </cfquery>
  40.  
  41. </cfloop>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement