首页Home › 编码与加密Encoding & Crypto
🗄️ 数据库密码哈希生成(MySQL / MariaDB / PostgreSQL)Database Password Hash Generator (MySQL, MariaDB, PostgreSQL)
生成 MySQL / MariaDB 的 mysql_native_password 哈希(PASSWORD() 结果)、PostgreSQL 的 MD5 与 SCRAM-SHA-256 密码串,并给出 CREATE USER / ALTER USER 语句。Generate MySQL/MariaDB mysql_native_password hashes (the PASSWORD() value) and PostgreSQL MD5 and SCRAM-SHA-256 password strings, with ready-to-run CREATE/ALTER USER statements.
使用说明与常见问题How-to & FAQ
「数据库密码哈希生成(MySQL / MariaDB / PostgreSQL)」是什么?What is the Database Password Hash Generator (MySQL, MariaDB, PostgreSQL) tool?
生成 MySQL / MariaDB 的 mysql_native_password 哈希(PASSWORD() 结果)、PostgreSQL 的 MD5 与 SCRAM-SHA-256 密码串,并给出 CREATE USER / ALTER USER 语句。Generate MySQL/MariaDB mysql_native_password hashes (the PASSWORD() value) and PostgreSQL MD5 and SCRAM-SHA-256 password strings, with ready-to-run CREATE/ALTER USER statements.
如何使用「数据库密码哈希生成(MySQL / MariaDB / PostgreSQL)」?How do I use the Database Password Hash Generator (MySQL, MariaDB, PostgreSQL)?
输入用户名和密码,下方同时给出 MySQL/MariaDB 与 PostgreSQL 两种格式的哈希及 SQL 语句。例如密码 password 的 MySQL 哈希是 *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19。SCRAM 的盐每次随机生成,可在选项中指定。Enter a user name and password to get both MySQL/MariaDB and PostgreSQL hashes plus SQL. For example, the MySQL hash of "password" is *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19. The SCRAM salt is random unless you set one.
MySQL 的 PASSWORD() 是怎么算的?How is MySQL's PASSWORD() computed?
mysql_native_password 的值是「*」加上 SHA1(SHA1(密码)) 的大写十六进制,共 41 个字符;MariaDB 使用相同算法。MySQL 8.0 默认改用 caching_sha2_password,但仍支持用这个哈希创建 mysql_native_password 用户(9.0 起已移除该插件)。mysql_native_password is "*" followed by the uppercase hex of SHA1(SHA1(password)) — 41 characters; MariaDB uses the same algorithm. MySQL 8.0 defaults to caching_sha2_password but still accepts this hash for mysql_native_password users (the plugin was removed in 9.0).
PostgreSQL 的 SCRAM 串由哪几部分组成?What is inside a PostgreSQL SCRAM string?
格式为 SCRAM-SHA-256$迭代次数:盐$StoredKey:ServerKey。SaltedPassword = PBKDF2-HMAC-SHA256(密码, 盐, 迭代次数),ClientKey 和 ServerKey 是对它做 HMAC 的结果,StoredKey = SHA-256(ClientKey),符合 RFC 5802 / RFC 7677。The format is SCRAM-SHA-256$iterations:salt$StoredKey:ServerKey. SaltedPassword = PBKDF2-HMAC-SHA256(password, salt, iterations); ClientKey and ServerKey are HMACs of it and StoredKey = SHA-256(ClientKey), per RFC 5802 / RFC 7677.
「数据库密码哈希生成(MySQL / MariaDB / PostgreSQL)」免费吗?数据会上传吗?Is the Database Password Hash Generator (MySQL, MariaDB, PostgreSQL) free? Is my data uploaded?
「数据库密码哈希生成(MySQL / MariaDB / PostgreSQL)」完全免费,无需注册或安装,手机和电脑都能用;所有处理都在你的浏览器本地完成,输入的内容和文件不会上传到服务器。The Database Password Hash Generator (MySQL, MariaDB, PostgreSQL) is completely free with no sign-up or install and works on phones and desktops; everything runs locally in your browser and nothing you enter is uploaded.