Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reverse sys(2007)

Status
Not open for further replies.

hellbound

Programmer
May 17, 2002
3
CA
I would like to know how to reverse sys(2007). It gives a 5 digit number or 4, when U type in a charater or charaters. I want to take that number and make it charaters again. Please let me know if U can do it and let me know how thanks.
 
'Scuse me while I ramble, but since it's a checksum, it would be based somehow on a calculation of the value of the character. This could potentially be more than one combination of different characters so I don't think reverse engineering it would be 100% reliable. Anyway, there isn't a built-in VFP function to handle it but maybe M$ has provided the formula somewhere.

Dave S.
 
Not reversable as far as I know because of the reasons stated above, it is a checkum which is not guarantied to be unique in reverse.

 
Since it is a checksum and is therefore lossy, you can only reliably reverse it when passing it a single character.

To make the reverser function, just pass it all the characters:

Code:
x=sys(2007,'a')
y=unSys2007(x)

FUNCTION unSys2007( pnChkSum )
LOCAL lnI
FOR lnI=0 to 255
  if sys(2007,chr(lnI))=pnChkSum
    RETURN chr(lnI)
  endif
ENDFOR
RETURN "I couldn't find it!"
 
wgcs

I'm not sure you solution works, because for example if you have the word "FOX" the checksum is 42398. And if you pass the each characters in the function you won't get "FOX". Your function would work on a single character only.
 
As everyone is saying, there's no unique reversal of a checksum. It's something of a trapdoor function. There are some other functions which work a lot like them which are reversable, however. The codes which are used as checksums in CD ROMs are designed so that if there's a single error the correct data can be recovered. I believe it's called 'Gray Coding' If you're trying to do something similar you might want to do a web search under 'error correction'. Dave Dardinger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top