【问题标题】:MySQL PASSWORD() function and SpringSecurity ShaPasswordEncoderMySQL PASSWORD() 函数和 SpringSecurity ShaPasswordEncoder
【发布时间】:2013-12-12 12:19:46
【问题描述】:

我有一个 mysql 数据库,它使用 MySQL 的 PASSWORD() 函数存储密码。从我可以从这个 URL 收集到的信息(并自己验证它以确保它适用于我的 MySQL 版本)

http://www.palominodb.com/blog/2011/12/04/hashing-algorithm-mysql-password

mysql 的散列函数是双 SHA1 散列,第一个结果从二进制转换为十六进制,然后再次散列。

SELECT PASSWORD("this_is_a_random_string") as 'pass';

pass: *12E76A751EFA43A177049262A2EE36DA327D8E50

SELECT concat('*', UPPER(SHA1(UNHEX(SHA1("this_is_a_random_string"))))) as 'pass';

pass: *12E76A751EFA43A177049262A2EE36DA327D8E50

所以我想做的是使用 SpringSecurity 的 ShaPasswordEncoder 来允许 Spring 使用这些哈希。

除了继承我自己的 PasswordEncoder 并使用 ShaPasswordEncoder 来构建上面 SQL 中显示的处理步骤之外,ShaPasswordEncoder 本身是否有一个标准的方法来设置自己以使用 MySQL 的 PASSWORD 函数?

【问题讨论】:

  • +1 有趣的揭示)但我同意比尔·卡尔文的回答。

标签: mysql hash spring-security


【解决方案1】:

http://dev.mysql.com/doc/refman/5.6/en/encryption-functions.html#function_password

PASSWORD() 函数被 MySQL Server 中的认证系统使用;您不应该在自己的应用程序中使用它。

【讨论】:

    猜你喜欢
    • 2010-11-17
    • 2013-05-13
    • 1970-01-01
    • 2011-08-19
    • 2013-06-18
    • 2018-11-25
    • 1970-01-01
    • 1970-01-01
    • 2022-12-12
    相关资源
    最近更新 更多