网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 Jenkins专有用户数据库加密算法简析
内容
    名单
    HudsonPrivateSecurityRealm.java详细路径是:jenkins/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java
    通过分析该源码得知:
    1、密文的格式为:salt: encPass,其中以#jbcrypt表示salt作为数据头
    2、明文通过jbcrypt算法得到密文 encPass
    关于jbcrypt:
    jbcrypt是bcrypt加密工具的java实现。
    它的API非常简单,DEMO如下,在HudsonPrivateSecurityRealm.java中可以看到加密和校验时使用了如下API:
    // Hash a password for the first time
    String hashed = BCrypt.hashpw(password, BCrypt.gensalt());
    // gensalt's log_rounds parameter determines the complexity the work factor is 2**log_rounds, and the default is 10
    String hashed = BCrypt.hashpw(password, BCrypt.gensalt(12));
    // Check that an unencrypted password matches one that has previously been hashed
    if (BCrypt.checkpw(candidate, hashed))
    System.out.println("It matches");
    else
    System.out.println("It does not match");
    经验证,用jbcrypt对同一个明文加密后因为salt一般不同,加密后的密文一般不同
    关于bcrypt:
    1、bcrypt是不可逆的加密算法,无法通过解密密文得到明文。
    2、bcrypt和其他对称或非对称加密方式不同的是,不是直接解密得到明文,也不是二次加密比较密文,而是把明文和存储的密文一块运算得到另一个密文,如果这两个密文相同则验证成功。
    综上,Jenkins专有用户数据库使用了jbcrypt加密,jbcrypt加密是不可逆的,而且对于同一个明文的加密结果一般不同。
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/17 4:16:52