星期三, 4月 13, 2011

圖片檔案hash

string hash = null;
                using (System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider())
                {
                    System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Jpeg;
                    System.Drawing.Image myImage = System.Drawing.Image.FromFile(path + f.ToString());
                    myImage.Save(ms, format);

                    hash = Convert.ToBase64String(sha1.ComputeHash(ms.ToArray()));
                }

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails