kettle(pdi)数据库连接中的密码的加密与解密


一、加密 :

进入kettle的安装目录

windows系统命令行执行:Encr.bat -kettle 123

linux/mac系统命令行执行:

encr.sh -kettle 123

linux环境kettle加密
可生成Encrypted 2be98afc86aa7f2e4cb79ce10bec3fd89,即为123对应的kettle加密后的密码。

二、java代码解密

首先添加kettle相关maven依赖

<!-- 缺少的jar包自行添加 -->
<dependency>
   <groupId>pentaho-kettle</groupId>
   <artifactId>kettle-core</artifactId>
   <version>8.1.0.0-365</version>
</dependency>
<dependency>
   <groupId>pentaho-kettle</groupId>
   <artifactId>kettle-engine</artifactId>
   <version>8.1.0.0-365</version>
</dependency>
 
<dependency>
   <groupId>pentaho</groupId>
   <artifactId>metastore</artifactId>
   <version>8.1.0.0-365</version>
</dependency>

加密代码

import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.encryption.Encr;
import org.pentaho.di.core.exception.KettleException;
 
/**
 * 破解kettle加密后的密码
 */
public class CrackPwd {
 
    public static void main(String[] args) {
        try {
            KettleEnvironment.init();
            String pwd = "Encrypted 2be98afc86aa7f2e4cb79f62886caf782";
            System.out.println("解码前密码:" + pwd);
            String decryptPassword = Encr.decryptPassword(pwd);
            System.out.println("解码后密码:" + decryptPassword);
        } catch (KettleException e) {
            e.printStackTrace();
        }
    }
}

总结

如果此篇文章有帮助到您, 希望打大佬们能关注点赞收藏评论支持一波,非常感谢大家!
如果有不对的地方请指正!!!

参考1
参考2

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lfwh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值