I try your Encrypt/decrypt function and the function don't works anytime. It seems like the string is too long then the function doesn't work.
Try your function with string : 11rrrrrrrrrrrrterwerwerwetwe
The function encrypt well the string but it doesn't decrypt the string that's encrypting before.
Effectively Dave, I found a solution. The problem was the transformation of value-128. I change the original tranformation by value+128 when it's under 0.
After test, it seems work. What do you think about this new code.
-------------------------
FUNCTION Mix (string1$,action$)
Dim Res$
Dim NxtChrVal%
Dim NxtChr$
Dim Stepper%
Dim cnt, x as integer
Res$ = ""
cnt = len(string1$)
Select Case action$
Case "E"
Stepper = 1
for x = 1 to cnt
NxtChrVal% = Asc(Mid(string1$,x,1))+(x*Stepper)
IF NxtChrVal% > 128 THEN NxtChrVal% = NxtChrVal% - 128
Res$ = Res$+Chr(NxtChrVal%)
next x
Case "D"
Stepper = -1
for x = 1 to cnt
NxtChrVal% = Asc(Mid(string1$,x,1))+(x*Stepper)
IF NxtChrVal% < 0 THEN NxtChrVal% = NxtChrVal% + 128
Res$ = Res$+Chr(NxtChrVal%)
next x
End Select
Mix = Res$
End function
----------------------------------
I found an other problem when I use an accent letter like éèê (in french). I modified value 128 by 256 then a couple of lines was modified.
replace
IF NxtChrVal% > 128 THEN NxtChrVal% = NxtChrVal% - 128
by
IF NxtChrVal% > 256 THEN NxtChrVal% = NxtChrVal% - 256
replace
IF NxtChrVal% < 0 THEN NxtChrVal% = NxtChrVal% + 128
by
IF NxtChrVal% < 0 THEN NxtChrVal% = NxtChrVal% + 256
Good job Giles. I had actuallly moved to a version that was even more restrictive (only a portion of the 128 ASCII set). Your version should support the full unicode set.
Regards,
Dave Griffin
The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data" Want good answers? Read FAQ401-2487 first!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.