-
-
Save stevepiercy/acf9d559e596e57f7c3a to your computer and use it in GitHub Desktop.
test of knop_crypthash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?lasso | |
// See http://lasso.2283332.n4.nabble.com/encryption-tt3140901.html#a3140908 | |
local(encpw) = null // the encrypted password variable | |
// sp_string_random is a Lasso 9 version of lp_string_random | |
local(salt) = knop_blowfish(-string = sp_string_random(50), -mode = 'E') | |
// local(salt) = sp_string_random(50) // encrypt the password with a salt | |
local(cost) = integer_random(20, 2000) | |
local(cipher) = 'RIPEMD160' | |
local(encpw) = 'moosehair' | |
'encpw: ' + #encpw | |
'<br>' | |
'salt: ' + #salt | |
'<br>' | |
'cost: ' + #cost | |
'<br>' | |
'cipher: ' + #cipher | |
'<br>' | |
'<br>' | |
// save user password | |
local(t_auth_c_hash) = knop_crypthash( | |
#encpw, | |
-cost=#cost, | |
-salt=#salt, | |
-cipher=#cipher, | |
-map=true | |
) | |
'The hash for the user password is ' + #t_auth_c_hash | |
'<br>' | |
'<br>' | |
// check user password where it's valid | |
local(entered_password) = 'moosehair' | |
// local(col_hash) = #db_user_hash -> find('hash')// pretend we pulled this from the user record, based on their username | |
'Is password valid? ' + (knop_crypthash( | |
#entered_password, | |
-hash=#t_auth_c_hash -> find('hash'), | |
-salt=#t_auth_c_hash -> find('salt'), | |
-cost=#t_auth_c_hash -> find('cost'), | |
-cipher=#cipher, | |
)) | |
'<br>' | |
// check user password where it's non-valid | |
local(entered_password) = 'Moosehair'// oops, user captialized the first letter, it won't work! | |
// local('col_hash' = #db_user_hash)// pretend we pulled this from the user record, based on their username | |
'Is password valid? ' + ( | |
knop_crypthash( | |
#entered_password, | |
-hash=#t_auth_c_hash -> find('hash'), | |
-salt=#t_auth_c_hash -> find('salt'), | |
-cost=#t_auth_c_hash -> find('cost'), | |
-cipher=#cipher, | |
)) | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment