中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

C# 計算文件SHA1值

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
 
public static string GetSHA1Hash(string pathName)
{
    string strResult = "";
    string strHashData = "";
    byte[] arrbytHashValue;

    System.IO.FileStream oFileStream = null;

    System.Security.Cryptography.SHA1CryptoServiceProvider osha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
    try
    {
        oFileStream = new System.IO.FileStream(pathName.Replace("\\"", ""), System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);

        arrbytHashValue = osha1 .ComputeHash(oFileStream); //計算指定Stream 對象的哈希值

        oFileStream.Close();

        //由以連字符分隔的十六進制對構(gòu)成的String,其中每一對表示value 中對應的元素;例如“F-2C-4A”

        strHashData = System.BitConverter.ToString(arrbytHashValue);

        //替換-
        strHashData = strHashData.Replace("-", "");

        strResult = strHashData;
    }

    catch (System.Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
    return strResult;
}
 

標簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇: 每天自動備份mysql腳本

下一篇: php實現(xiàn)三級導航欄效果