Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sys(2007) in .net
Message
From
02/03/2005 09:37:22
 
 
To
02/03/2005 08:37:58
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
00991929
Message ID:
00991954
Views:
20
This message has been marked as the solution to the initial question of the thread.
>Hello,
>How can I implement the equivalent to sys(2007) in vb.net?
>I do not mean some checksum function, I need to generate the exact same output given the same input.
>
>Thanks in advance.

Oscar,

Here is C# implementation of SYS( 2007) function:
public static ushort Sys2007( string strExpr)
{
	ushort result = 0xFFFF;
	byte[] bytes = System.Text.Encoding.Default.GetBytes( strExpr);
	for( int curPos = 0; curPos < bytes.Length; curPos++)
	{
		result = (ushort)(( result << 8) + (byte)( result >> 8));
		result ^= bytes[curPos];
		result ^= (ushort)(( result >> 4) & 0x0F);
		result ^= (ushort)(((byte)( result & 0xFF) ^ (result << 7)) << 5);
	}
	return result;
}
HTH
Alex
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform