Data type: Difference between revisions

Jump to navigation Jump to search
1,434 bytes added ,  6 January 2025
→‎雜湊碼 (hash value) e.g. MD5, SHA: Hash Algorithm Output and Schema Reference
(→‎雜湊碼 (hash value) e.g. MD5, SHA: Hash Algorithm Output and Schema Reference)
Line 80: Line 80:


=== 雜湊碼 (hash value) e.g. MD5, SHA ===
=== 雜湊碼 (hash value) e.g. MD5, SHA ===
'''Hash Algorithm Output and Schema Reference'''
<ref>[https://en.wikipedia.org/wiki/Secure_Hash_Algorithms Secure Hash Algorithms - Wikipedia]</ref>
<table border="1" class="wikitable sortable">
      <tr>
          <th>Algorithm</th>
          <th>Output Size (bits)</th>
          <th>Max Length (chars)</th>
          <th>Schema Recommendation</th>
      </tr>
      <tr>
          <td>MD5</td>
          <td>128</td>
          <td>32</td>
          <td>char(32)</td>
      </tr>
      <tr>
          <td>SHA-1</td>
          <td>160</td>
          <td>40</td>
          <td>char(40)</td>
      </tr>
      <tr>
          <td>SHA-224</td>
          <td>224</td>
          <td>56</td>
          <td>char(56)</td>
      </tr>
      <tr>
          <td>SHA-256</td>
          <td>256</td>
          <td>64</td>
          <td>char(64)</td>
      </tr>
      <tr>
          <td>SHA-384</td>
          <td>384</td>
          <td>96</td>
          <td>char(96)</td>
      </tr>
      <tr>
          <td>SHA-512</td>
          <td>512</td>
          <td>128</td>
          <td>char(128)</td>
      </tr>
</table>
Explain the conversion process from 224 bits to 56 characters for SHA-224's output. Conversion process:
* "Original output: 224 bits"
* Every 4 bits converts to 1 hexadecimal character (hex character): 224 ÷ 4 = 56
* Therefore, it requires 56 hexadecimal characters to represent
[https://zh.wikipedia.org/wiki/MD5 MD5]: {{exclaim}} Not recommended to use this function to secure passwords
[https://zh.wikipedia.org/wiki/MD5 MD5]: {{exclaim}} Not recommended to use this function to secure passwords
* Data type: CHAR(32) or VARCHAR(32)<ref>[https://stackoverflow.com/questions/14922208/can-i-use-varchar32-for-md5-values php - Can I use VARCHAR(32) for md5() values? - Stack Overflow]</ref>
* Data type: CHAR(32) or VARCHAR(32)<ref>[https://stackoverflow.com/questions/14922208/can-i-use-varchar32-for-md5-values php - Can I use VARCHAR(32) for md5() values? - Stack Overflow]</ref>

Navigation menu