Hello I am trying to convert this delphi to C#
1. var 2. i: LongInt; 3. iCount: LongInt; 4. p: pchar; 5. begin 6. iCount := 0; 7. for i := 1 to length(str) do 8. iCount := iCount * 997 + Ord(str[i]); 9. 10. i := length(str); 11. p := pointer(@str[i]); 12. i := 4 - i; 13. 14. while i < 0 do 15. begin 16. iCount := (((iCount*997+ord(p[i-3]))*997+ord(p[i-2]))*997+ord(p[i -1]))*997+ord(p[i])); 17. inc(i,4); 18. end; 19. 20. i := i - 3; 21. while i < 0 do 22. begin 23. iCount := iCount * 997 + ord(p[i]); 24. inc(i); 25. end; could any one tell me what i am doing wrong. I am not getting the same hash public String hashPassword(String str) { String res = ""; long i = 0; long iCount = 0; int endposstr = str.Length-1; for (i = 0; i < endposstr; i++) { iCount = iCount * 997 + charValue(str[(int)i]); } i = 4 - (endposstr + 1); while (i < 0) { char c1 = str[(int)(endposstr - 3)]; char c2 = str[(int)(endposstr - 2)]; char c3 = str[(int)(endposstr - 1)]; char c4 = str[(int)endposstr]; iCount = ((((iCount * 997 + charValue(c1)) * 997 + charValue(c2)) * 997 + charValue(c3)) * 997 + charValue(c4)); i = i + 4; } i = i - 3; while(i < 0){ iCount = iCount * 997 + charValue(str[(int)(endposstr)]); i++; } res = iCount.ToString(); return res; } public int charValue(char c) { return (int)c; } thanks [Non-text portions of this message have been removed]