technobuddha
28th August 2012 21:49 UTC
NsisCrypt plug-in not working or ?
Hi all,
I'm trying to use the NsisCrypt plug-in, because i need to convert a variable into SHA1, which goes into a mysql database.
I know what the password is and how it looks with SHA1:
variable = traytray
converted = a8f3dd5acc59b8029fb68402159e222d604e938a
but when in script, i use:
NsisCrypt::Hash "traytray" "sha1"
Pop $1
MessageBox MB_OK $1
it comes out with:
bgCF8ywhjC98c10dkHJLM0McYBg=
so am I using this wrongly?
or is there something else that will convert ascii to mysql "SHA1"....
Anders
28th August 2012 23:39 UTC
Did you read the wiki page? It says the return value is base64 encoded.
technobuddha
29th August 2012 03:35 UTC
ok, i get the logic now. thanks so much for clarifying that!
but i'm still wanting it to come back as ascii, so I can put it into a mysql sql statement.
do i need to then convert from base64 to ascii with ANOTHER plugin?
Anders
29th August 2012 03:56 UTC
It has a base64 decode function...
technobuddha
29th August 2012 14:07 UTC
Hi Anders,
thanks for your time,
but in my noob experience with nsis,
it only returns an "n"
but i could be doing the code wrong.
NsisCrypt::Hash "traytray" "sha1"
Pop $1
MessageBox MB_OK $1
NsisCrypt::Base64Decode $1
Pop $1
MessageBox MB_OK $1
demiller9
29th August 2012 16:54 UTC
The Hash function appears to use $1 as well as the two parameters passed on the calling line. [ From the Wiki page: ] " If you set NSIS user variable $1 to phrase 'ascii', the[n] the string is hashed as an ASCII string, otherwise, the string is behaved like a unicode one."
Your example doesn't set $1 to "ascii", so the string is processed as Unicode, and Base64Decode will give back Unicode characters. The MessageBox probably sees the first character as just one character and an end of string.