Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MD5 Hash
Message
From
07/05/2009 04:48:40
 
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Title:
Miscellaneous
Thread ID:
01398270
Message ID:
01398298
Views:
125
Bud,

I have done one test with the fll and MD5CryptoServiceProvider()
Works for me

dunno - but are both sides utf7 or utf8 ?
The basic md5 tests are
&& bit of foxpro code

		do case
		case !m.Success
		
		case !.TestString("", "d41d8cd98f00b204e9800998ecf8427e")
			assert FALSE
			Success = FALSE
			
		case !.TestString("a", "0cc175b9c0f1b6a831c399e269772661")
			assert FALSE
			Success = FALSE
			
		case !.TestString("abc", "900150983cd24fb0d6963f7d28e17f72")
			assert FALSE
			Success = FALSE
		
		case !.TestString("message digest", "f96b697d7cb7938d525a2f31aaf161d0")
			assert FALSE
			Success = FALSE
		
		case !.TestString("abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b")
			assert FALSE
			Success = FALSE
		
		case !.TestString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ;
							 "d174ab98d277d9f5a5611c2c9f419d9f")
			assert FALSE
			Success = FALSE
		
		case !.TestString("12345678901234567890123456789012345678901234567890123456789012345678901234567890", ;
				"57edf4a22be3c955ac49da2e2107b67a")
		
			assert FALSE
			Success = FALSE
		
		endcase

// 
namespace GregoryAdam.Test
{
	public static class xxx
	{
		public static void Main()
		{
			using (MD5 md5 = new MD5CryptoServiceProvider())
			{

				string test = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
				byte[] bb = Encoding.UTF8.GetBytes(test);

				var result = md5.ComputeHash(bb);
				Console.WriteLine("len = {0}", result.Length);

				var sb = new StringBuilder();
				for (int i = 0; i < result.Length; i++)
				{
					sb.Append(result[i].ToString("X2"));
					Console.Write("{0:X2}  ", result[i]);
				}

				Console.WriteLine();
				Console.WriteLine(sb.ToString()); // D174AB98D277D9F5A5611C2C9F419D9F
				Console.ReadLine();

			}
		}
	}
}

>I am struggling to create an MD5 hash in VFP and I can then compare to a hash in .Net.
>
>I am using VFPEncryption.FLL to generate a MD5Hash that I then STRCONV (hashResult,15) and send to my .Net web service.
>
>In .Net I am using:
>
>
>          MD5 md5 = new MD5CryptoServiceProvider();
>            var result = md5.ComputeHash(bytes);
>
>            var SB = new StringBuilder();
>            var sb = new StringBuilder();
>            for (var i = 0; i < result.Length; i++)
>            {
>                sb.Append(result[i].ToString("X2"));
>                SB.Append(result[i].ToString("x2"));
>            }
>            return sb.ToString();
>
>
>
>But the results are never equal.
>
>I have compared the input to both functions and they are equal.
>
>Am I taking the wrong approach?
>
>Any insight you could provide would be greatly appreciated.
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform