Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sys(2007) in .net
Message
De
02/03/2005 09:37:22
 
 
À
02/03/2005 08:37:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
00991929
Message ID:
00991954
Vues:
19
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform