14,954
edits
(+國際電話號碼) |
(→密碼) |
||
| Line 72: | Line 72: | ||
=== 密碼 === | === 密碼 === | ||
* varchar at least eight (8) characters<ref>[https://www.owasp.org/index.php/Password_length_%26_complexity Password length & complexity - OWASP] "Minimum length. Passwords should be at least eight (8) characters long." </ref> | * varchar at least eight (8) characters<ref>[https://www.owasp.org/index.php/Password_length_%26_complexity Password length & complexity - OWASP] "Minimum length. Passwords should be at least eight (8) characters long." </ref> | ||
=== 雜湊碼 (hash value) === | |||
* [https://zh.wikipedia.org/wiki/MD5 MD5]: CHAR(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> | |||
* [https://zh.wikipedia.org/wiki/SHA%E5%AE%B6%E6%97%8F SHA] 256<ref>[https://stackoverflow.com/questions/2240973/how-long-is-the-sha256-hash mysql - How long is the SHA256 hash? - Stack Overflow]</ref>: | |||
** (1) HEX: CHAR(64) Using [http://php.net/manual/en/function.hash-file.php PHP: hash_file()], MySQL [https://dev.mysql.com/doc/refman/5.6/en/encryption-functions.html#function_sha2 SHA2(str, hash_length)] | |||
** (2) Binary: BINARY(32) Using [http://php.net/manual/en/function.hex2bin.php hex2bin()] in PHP e.g. {{kbd | key=<nowiki>echo hex2bin(hash_file('sha256', $file_path));</nowiki>}}, In MySQL e.g. {{kbd | key=<nowiki>SELECT UNHEX(SHA2('The quick brown fox jumped over the lazy dog.', 256))</nowiki>}} | |||
PHP: | |||
<pre> | |||
<?php | |||
/* Create a file to calculate hash of */ | |||
file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.'); | |||
echo hash_file('sha256', 'example.txt'); | |||
// expected result: 68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483 | |||
// 64 characters | |||
// calculate the hash of string | |||
echo hash('sha256', 'The quick brown fox jumped over the lazy dog.'); | |||
?> | |||
</pre> | |||
MySQL: | |||
<pre> | |||
SELECT SHA2('The quick brown fox jumped over the lazy dog.', 256) | |||
</pre> | |||
=== membership === | === membership === | ||