作者: mankowk 時間: 2018-1-19 13:50 標題: 關於 MySQL ENCRYPT()
我在 MySQL 試下 ENCRYPT()
1. SELECT ENCRYPT('123456789',CONCAT('$7$',SUBSTRING(SHA(RAND()),2)));
出 NULL
2. SELECT ENCRYPT('123456789',CONCAT('$6$',SUBSTRING(SHA(RAND()),2)));
出 一堆字串
請問各位師兄, 點解會出 NULL,
我試到 $1$ and $6$ 都有字串出,
$2$, $3$, $4$, $7$ 好多都出 NULL.
- SELECT ENCRYPT('123456789',CONCAT('$7,SUBSTRING(SHA(RAND()),2)));
- SELECT ENCRYPT('123456789',CONCAT('$6,SUBSTRING(SHA(RAND()),2)));
作者: rabbit82047 時間: 2018-1-19 14:11
本帖最後由 rabbit82047 於 2018-1-19 14:14 編輯
因為 7 唔係正確 ID, 基本上只可用 1, 5, 6
If salt is a character string starting with the characters "$id$"
followed by a string optionally terminated by "$", then the result
has the form:
$id$salt$encrypted
id identifies the encryption method used instead of DES and this then
determines how the rest of the password string is interpreted. The
following values of id are supported:
ID | Method
1 | MD5
2a | Blowfish (not in mainline glibc; added in some Linux distributions)
5 | SHA-256 (since glibc 2.7)
6 | SHA-512 (since glibc 2.7)
因為 mysql encrypt 係用 system crypt
Linux crypt man page:
http://man7.org/linux/man-pages/man3/crypt.3.html
作者: mankowk 時間: 2018-1-19 14:58
回覆 2# rabbit82047
原來係咁、明白晒、3q
