V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zq9610
V2EX  ›  问与答

如何在 Mysql 语句中使用 CRAM-MD5 方式对密码编码?

  •  
  •   zq9610 · 2014-12-14 02:53:49 +08:00 · 3068 次点击
    这是一个创建于 3637 天前的主题,其中的信息可能已经有所发展或是发生改变。
    现有roundcube+postfixadmin的环境,
    用了roundcube自带的password插件修改密码,但是postfixadmin的密码加密方式是CRAM-MD5,
    下面这句就是明文的,
    UPDATE mailbox SET password=%p WHERE username=%u

    我在phpmyadmin里面看到CRAM-MD5编码方式得到的是
    {CRAM-MD5}e242eae7d898607cdade67c99081da7b56fc60aa9acfceb9016b21c80b6872f3
    (对应)ABC@123456

    怎么写这句sql语句来更新密码呢?

    // The SQL query used to change the password.
    // The query can contain the following macros that will be expanded as follows:
    // %p is replaced with the plaintext new password
    // %c is replaced with the crypt version of the new password, MD5 if available
    // otherwise DES. More hash function can be enabled using the password_crypt_hash
    // configuration parameter.
    // %D is replaced with the dovecotpw-crypted version of the new password
    // %o is replaced with the password before the change
    // %n is replaced with the hashed version of the new password
    // %q is replaced with the hashed password before the change
    // %h is replaced with the imap host (from the session info)
    // %u is replaced with the username (from the session info)
    // %l is replaced with the local part of the username
    // (in case the username is an email address)
    // %d is replaced with the domain part of the username
    // (in case the username is an email address)
    // Escaping of macros is handled by this module.
    // Default: "SELECT update_passwd(%c, %u)"
    $config['password_query'] = 'UPDATE mailbox SET password=%d WHERE username=%u';
    1 条回复    2014-12-14 14:28:27 +08:00
    zq9610
        1
    zq9610  
    OP
       2014-12-14 14:28:27 +08:00 via iPad
    没有人做过吗?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1252 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 18:21 · PVG 02:21 · LAX 10:21 · JFK 13:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.