Here's the C++ method:
and here's the core of the NSIS function:int calculateId(LPTSTR email)
{
unsigned int x = 0;
for (int i = 0; i < strlen(email); i++) {
x = x * 101;
x = x + towlower(email[i]);
}
return x;
}
These two methods seem to be giving two different results. Calling calculateId(email@somplace.com) gives "2849034273" where as in NSIS it is giving "-1319540362". However, I've tried debugging and it seems that when you call the two functions with the first few characters, they give the same result. Once the string becomes longer, NSIS starts giving negative values. Now I'm no NSIS expert, so I was wondering if it had to do with the nature of variables in NSIS or something else. Thank you.StrCpy $3 0
System::Call "*(&w1024 'email@someplace.com')i.r0"
StrCpy $1 $0
System::Call "*$0(&i2.r2)"
${While} $2 != 0
IntOp $3 $3 * 101
IntOp $3 $3 + $2
IntOp $0 $0 + 2
System::Call "*$0(&i2.r2)"
${EndWhile}
System::Free $1