Wednesday, December 11, 2013

How to make a MD5 hash from a string?

        public string CalculateMD5Hash(string input)
        {
            // step 1, calculate MD5 hash from input
            MD5 md5 = System.Security.Cryptography.MD5.Create();
            byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
            byte[] hash = md5.ComputeHash(inputBytes);

            // step 2, convert byte array to hex string
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < hash.Length; i++)
            {
                sb.Append(hash[i].ToString("X2"));
            }
            return sb.ToString();
        }

Reference:
http://blogs.msdn.com/b/csharpfaq/archive/2006/10/09/how-do-i-calculate-a-md5-hash-from-a-string_3f00_.aspx

What is BSON

Stand for Bin­ary JSON
It is Lightweight, Traversable and Efficient
http://bsonspec.org/



Tuesday, December 10, 2013

How to solve Entity Framework “Invalid Column Name” problem?

Most of cases, because the schema of current database is different with original one.

Compare two database schema to find out the difference.

How to solve "LINQ to Entities does not recognize the method" problem

Linq will convert syntax into a SQL expression. If any method is not available in SQL query, will get this error.
Such as:
- NQ to Entities does not recognize the method System.Guid Parse(System.String) method, and this method cannot be translated into a store expression.
- NQ to Entities does not recognize the method 'System.String ToString()' method


Solution:
Prepare value before run LINQ query..


A re-introduction to JavaScript

https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript?redirectlocale=en-US&redirectslug=JavaScript%2FA_re-introduction_to_JavaScript