• MySQL加密解密


    1. 加密:mysql323,不可逆

    select old_password('bbs.antian365.com');
    # 10c886615b135b38

    2. 加密:mysqlsha1,不可逆

    select password('bbs.antian365.com');
    # *A2EBAE36132928537ADA8E6D1F7C5C5886713CC2

    3. 加密:md5,不可逆

    select md5('bbs.antian365.com');
    # 3e8ec6f4db678dc7bf9ef71cd6c8b266

    4. 加密解密:encode()和decode()

    都有两个参数,第一个是实际需要保存的值,第二个是盐。

            # 建一张测试表
            create table users(
                username varchar(128), # 用户昵称
                password blob #密码
            ) engine=innodb default charset=utf8;
            
            # 插入一条测试语句
            INSERT INTO users (username, password) VALUES ('john', ENCODE('guessme', 'salt')); 
            commit;
            
            # 查询john的密码(用的mysql workbench)
            select t.username, DECODE(t.password,'salt') as password from users t where t.username = 'john';
            # 在查询结构的password值上,右键,'open value in viewer'。可以看到text TAB下的密码明文。

    查看密码明文:

    5. 加密解密:aes_encrypt()和aes_decrypt()

    都有两个参数,第一个是实际需要保存的值,第二个是盐。

    比encode()和decode()安全性要高。有说,在windows下不可用,我在windows下测试,可以正常执行。

            # 测试表,同样使用users
            
            # 插入一条语句
            INSERT INTO users (username, password) VALUES ('steven', aes_encrypt('password', 'salt')); 
            commit;
            
            # 查询steven的密码(用的mysql workbench)
            select t.username, aes_decrypt(t.password,'salt') as password from users t where t.username = 'steven';

     查看密码明文:

  • 相关阅读:
    Kappa Architecture: A Different Way to Process Data
    Lambda architecture and Kappa architecture
    Questioning the lambda architecure
    Lambda Architecture: Achieving Velocity and Volume with Big Data
    beego 参数配置
    hadoop 3.1.1 安装
    Idea 切换git账号
    IntelliJ IDEA 开发git多模块项目
    打印1到1亿的平方
    IDEA 逆向工程
  • 原文地址:https://www.cnblogs.com/zj0208/p/7682791.html
Copyright © 2020-2023  润新知