• C# 文件 校验:MD5、SHA1、SHA256、SHA384、SHA512、CRC32、CRC64


    文件 校验 算法:MD5、SHA1、SHA256、SHA384、SHA512、CRC32、CRC64 (免费)

    编程语言:C#

    功能:文件 哈希 属性

    校验算法:MD5、SHA1、SHA256、SHA384、SHA512、CRC32、CRC64。

    下载(免费):https://download.csdn.net/download/polloo2012/88450148
     

    本程序 File Properties and Hash Validation.exe 验证:

    MD5: DD3BE641301A54E093CAC2C15823491A
    SHA1: 711330AD0E0BB25D6E6E6AD2BE1ACEE1830C7FBD
    SHA256: CEF9D7915425C96C6C73BF212D7C7E6D8A3D90028DFA4278B0E351B3C63BE3EA
    SHA384: F6115FCF1C4E08A571D87441E72C163291677D5644A983CE8DD068F1B3386413CFC3390DF0AE47A41B5F90145F798C01
    SHA512: 93DDBF61CA0F10500141AB6D78B156C2AB6EEA4A777A8C90D58F40D42BDF5CEE1E0DAAE0258ECB748640CFD07AB5B47EC97E28D929818250D8F1E613C4EF4BA6
    CRC32: B5504085
    CRC64: E9D486C6CF48506A

    更新:2023年10月21日

    1、注册windows右键 支持右键

    更新时间:2023年10月26日 (不再更新)

    1、普通 和 多线程(默认 多线程)

    2、修改一些布局,增加 右下菜单

    核心代码:

    1. using System;
    2. using System.Collections.Generic;
    3. using System;
    4. using System.Text;
    5. using System.Threading;
    6. using System.Security;
    7. using System.Security.Cryptography;
    8. using System.Data.HashFunction;
    9. namespace HashChecker
    10. {
    11. ///
    12. /// There are some kinds of hash algorithm in this class likes MD5, SHA1, SHA256, SHA384, SHA512, CRC32, CRC64.
    13. /// 此类提供MD5,SHA1,SHA256,SHA384,SHA512,CRC32,CRC64等几种数据摘要算法。
    14. ///
    15. public static class HashFunction
    16. {
    17. ///
    18. /// Caculate string's MD5 value. 计算字符串的MD5值。
    19. ///
    20. /// input string. 输入的字符串。
    21. /// Return MD5 value. 返回MD5值。
    22. public static string md5(string strIN)
    23. {
    24. return md5(System.Text.Encoding.Default.GetBytes(strIN));
    25. }
    26. ///
    27. /// Caculate string's MD5 value. 计算字符串的MD5值。
    28. ///
    29. /// input Byte Array. 输入的字节数组。
    30. /// Return MD5 value. 返回MD5值。
    31. public static string md5(Byte[] btIN)
    32. {
    33. System.Security.Cryptography.MD5 md5 = new MD5CryptoServiceProvider();
    34. byte[] bytResult = md5.ComputeHash(btIN);
    35. md5.Clear();
    36. string strResult = BitConverter.ToString(bytResult);
    37. strResult = strResult.Replace("-", "");
    38. return strResult;
    39. }
    40. ///
    41. /// Caculate string's SHA1 value. 计算字符串的SHA1值。
    42. ///
    43. /// input string. 输入的字符串。
    44. /// Return SHA1 value. 返回SHA1值。
    45. public static string sha1(string strIN)
    46. {
    47. return sha1(System.Text.Encoding.Default.GetBytes(strIN));
    48. }
    49. ///
    50. /// Caculate string's SHA1 value. 计算字符串的SHA1值。
    51. ///
    52. /// input Byte Array. 输入的字节数组。
    53. /// Return SHA1 value. 返回SHA1值。
    54. public static string sha1(byte[] btIN)
    55. {
    56. byte[] tmpByte;
    57. SHA1 sha1 = new SHA1CryptoServiceProvider();
    58. tmpByte = sha1.ComputeHash(btIN);
    59. sha1.Clear();
    60. string strResult = BitConverter.ToString(tmpByte);
    61. strResult = strResult.Replace("-", "");
    62. return strResult;
    63. }
    64. ///
    65. /// Caculate string's SHA256 value. 计算字符串的SHA256值。
    66. ///
    67. /// input string. 输入的字符串。
    68. /// Return SHA256 value. 返回SHA256值。
    69. public static string sha256(string strIN)
    70. {
    71. return sha256(System.Text.Encoding.Default.GetBytes(strIN));
    72. }
    73. ///
    74. /// Caculate string's SHA256 value. 计算字符串的SHA256值。
    75. ///
    76. /// input Byte Array. 输入的字节数组。
    77. /// Return SHA256 value. 返回SHA256值。
    78. public static string sha256(byte[] btIN)
    79. {
    80. byte[] tmpByte;
    81. SHA256 sha256 = new SHA256Managed();
    82. tmpByte = sha256.ComputeHash(btIN);
    83. sha256.Clear();
    84. string strResult = BitConverter.ToString(tmpByte);
    85. strResult = strResult.Replace("-", "");
    86. return strResult;
    87. }
    88. ///
    89. /// Caculate string's SHA384 value. 计算字符串的SHA384值。
    90. ///
    91. /// input string. 输入的字符串。
    92. /// Return SHA384 value. 返回SHA384值。
    93. public static string sha384(string strIN)
    94. {
    95. return sha384(System.Text.Encoding.Default.GetBytes(strIN));
    96. }
    97. ///
    98. /// Caculate string's SHA384 value. 计算字符串的SHA384值。
    99. ///
    100. /// input Byte Array. 输入的字节数组。
    101. /// Return SHA384 value. 返回SHA384值。
    102. public static string sha384(byte[] btIN)
    103. {
    104. byte[] tmpByte;
    105. SHA384 sha384 = new SHA384Managed();
    106. tmpByte = sha384.ComputeHash(btIN);
    107. sha384.Clear();
    108. string strResult = BitConverter.ToString(tmpByte);
    109. strResult = strResult.Replace("-", "");
    110. return strResult;
    111. }
    112. ///
    113. /// Caculate string's SHA512 value. 计算字符串的SHA512值。
    114. ///
    115. /// input string. 输入的字符串。
    116. /// Return SHA512 value. 返回SHA512值。
    117. public static string sha512(string strIN)
    118. {
    119. return sha512(System.Text.Encoding.Default.GetBytes(strIN));
    120. }
    121. ///
    122. /// Caculate string's SHA512 value. 计算字符串的SHA512值。
    123. ///
    124. /// input Byte Array. 输入的字节数组。
    125. /// Return SHA512 value. 返回SHA512值。
    126. public static string sha512(byte[] btIN)
    127. {
    128. byte[] tmpByte;
    129. SHA512 sha512 = new SHA512Managed();
    130. tmpByte = sha512.ComputeHash(btIN);
    131. sha512.Clear();
    132. string strResult = BitConverter.ToString(tmpByte);
    133. strResult = strResult.Replace("-", "");
    134. return strResult;
    135. }
    136. ///
    137. /// Caculate string's CRC32 value. 计算字符串的循环冗余校验码CRC32值。
    138. ///
    139. /// input string. 输入的字符串。
    140. /// Return CRC32 value. 返回CRC32值。
    141. public static string crc32(string strIN)
    142. {
    143. return crc32(strIN);
    144. }
    145. ///
    146. /// Caculate string's CRC32 value. 计算字符串的循环冗余校验码CRC32值。
    147. ///
    148. /// input Byte Array. 输入的字节数组。
    149. /// Return CRC32 value. 返回CRC32值。
    150. public static string crc32(byte[] btIN)
    151. {
    152. return crc_caculator(btIN, CRC.Standard.CRC32);
    153. }
    154. ///
    155. /// Caculate string's CRC64 value. 计算字符串的循环冗余校验码CRC64值。
    156. ///
    157. /// input string. 输入的字符串。
    158. /// Return CRC64 value. 返回CRC64值。
    159. public static string crc64(string strIN)
    160. {
    161. return crc64(strIN);
    162. }
    163. ///
    164. /// Caculate string's CRC64 value. 计算字符串的循环冗余校验码CRC64值。
    165. ///
    166. /// input Byte Array. 输入的字节数组。
    167. /// Return CRC64 value. 返回CRC64值。
    168. public static string crc64(byte[] btIN)
    169. {
    170. return crc_caculator(btIN, CRC.Standard.CRC64);
    171. }
    172. ///
    173. /// CRC Caculator. CRC循环冗余校验码计算器
    174. ///
    175. /// input Byte Array. 输入的字节数组。
    176. /// CRC Standard. CRC计算标准。
    177. /// Return CRC value. 返回CRC值。
    178. public static string crc_caculator(byte[] btIN, CRC.Standard standard)
    179. {
    180. CRC.Setting crcset = CRC.Standards[standard];
    181. System.Data.HashFunction.CRC crc = new CRC(crcset);
    182. byte[] tmpByte = crc.ComputeHash(btIN);
    183. string strResult = BitConverter.ToString(tmpByte);
    184. strResult = strResult.Replace("-", "");
    185. return strResult;
    186. }
    187. }
    188. }
  • 相关阅读:
    Git快速入门一篇文章就够了。Git基础使用。如何将本地的文件上传到Gitee?
    K8S哲学 - probe 探针
    REUSE_ALV_GRID_DISPLAY详解
    牛客SQL实战
    ArkUI-X+HarmonyOS Next跨平台App开发
    【博学谷学习记录】超强总结,用心分享|SSH免密登录|附带自动脚本
    NAND Flash原理
    人工智能指数报告2023
    Pycharm中新建一个文件夹下__init__.py文件有什么用
    tcpdump常用命令
  • 原文地址:https://blog.csdn.net/polloo2012/article/details/133948371