private byte[] InternalComputeHash(string password) { if (password == null) { throw new ArgumentNullException("password"); } //prepare password, padding to 14 bytes if not enough, otherwise cutting the part exceeding 14 bytes password = password.ToUpper(); byte[] passwordBuffer; if (password.Length > lmHashPasswordLength) { passwordBuffer = Encoding.ASCII.GetBytes(password.ToCharArray(), 0, lmHashPasswordLength); } else { byte[] temp = Encoding.ASCII.GetBytes(password); passwordBuffer = new byte[lmHashPasswordLength]; Array.Copy(temp, passwordBuffer, temp.Length); } //insert zero ervery 7 bits to generate two keys used in Des encrypt byte[] password1 = GenerateDesKey(passwordBuffer, 0); //get the key starting from half of passwordArray's length position. byte[] password2 = GenerateDesKey(passwordBuffer, passwordBuffer.Length / 2); //use Des with ECB CipherMode and NONE padding option to encrypt "KGS!@#$%" byte[] hashDataBuffer = Encoding.ASCII.GetBytes(this.lmHashData); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); des.Mode = CipherMode.ECB; des.Padding = PaddingMode.None; // DES class performs weak key check so that some short-length keys may fail // We call its method to create ICryptoTransform directly to bypass the check. const string methodName = "_NewEncryptor"; object[] desParams = new object[] { password1, des.Mode, null, des.FeedbackSize, 0 }; ICryptoTransform ct1 = (ICryptoTransform)ObjectUtility.InvokeMethod(des, methodName, desParams); byte[] hash1 = ct1.TransformFinalBlock(hashDataBuffer, 0, hashDataBuffer.Length); desParams[0] = password2; ICryptoTransform ct2 = (ICryptoTransform)ObjectUtility.InvokeMethod(des, methodName, desParams); byte[] hash2 = ct2.TransformFinalBlock(hashDataBuffer, 0, hashDataBuffer.Length); //concatenate the two encrypted text to one. byte[] ConcatenatedArray = Helper.ConcatenateByteArrays(hash1, hash2); return(ConcatenatedArray); }