Archive: math::script problem


math::script problem
after writing something like a string scrambler I discovered following problem: when crypting a string with odd number of characters, it works fine, when with even number of characters, the last one doesn't get encrypted.

I'm basically just adding the char values of 2 strings together.

secret + emailadress =

secretsecre
emailadress
-----------
\VH_UY[[Li\

Any help on that?

encrypt:
Strcpy $7 "$3,$1,$2,$4"
Strcpy $8 "secret"
StrLen $5 $7
StrLen $6 $8
Math::Script /NOUNLOAD "tlength = r5; slength = r6"
Math::Script /NOUNLOAD "counter1 = 0; counter2 = 0; counter3 = 0; text = r7; secret = r8; textarray = a(text); secretarray = a(secret); z = {}; #{counter1<tlength, z[counter1] = (((c(text[counter1])+c(secret[counter3]))-88)%80)+44; counter1++; counter2++; counter3 = counter2%slength}; r9 = s(z)"
MessageBox MB_ICONQUESTION|MB_YESNO "Is your Information correct? $\n$\n$\n First name: $1 $\n$\n Last name: $2 $\n$\n Email Address: $3 $\n Mailinglist: $7 $\n$9" IDNO back IDYES inetdown
thx markus

--
markus heckmann
www.derivativeinc.com
the artform for live visuals

Seems like the array of type {} needs a terminating null. Use z[counter1] = 0 after the loop and it should work.