cgi - Perl crypt() acting weird -
Once I'm using the function below to create a hash for download link (originally from prelomax) weird thing It is that I always get the same hash result.
I'm RTFMing I've ensured that the crypt () function gets the last 8 characters of $ EXP, and $ EXP actually verifies changes too. I manually encrypt the crypt () function Have tried to feed with random values, only those people have done the right thing and hash result has changed.
What am I missing here?
Strict use; Use CGI; Sub Chash {My $ exp = $ _; My $ key = 'abcd1234'; // is not real $ my hash = crypt (substr ($ exp, -8,8), $ key); $ Hash = substart ($ hash, 2); $ Hash = ~ s / [^ a-zA-Z0- 9] // g; $ Hash = UK ($ hash); Return $ hash; } $ Exp = time () + 60; My $ hash = wrench ($ EXP); My $ download_url = "http://script.pl?$exp-$hash";
You want to drag items before @_ Instead of trying to read $ _ in the sub my $ exp = shift; or
My ($ exp) = @_; or
my $ exp = $ _ [0]; From to:
Any argument that is shown in the array @_ . Therefore, if you call functions with two arguments, then they will be stored in $ _ [0] and $ _ [1] . The array @_ is a local array, but its elements are nicknames for the actual scalar parameter.
Comments
Post a Comment