kettle(pdi)数据库连接中的密码的加密与解密
1.加密
进入kettle的安装目录
windows系统命令行执行:Encr.bat -kettle 123
linux/mac系统命令行执行:encr.sh -kettle 123
可生成Encrypted 2be98afc86aa7f2e4cb79ce10bec3fd89,即为123对应的kettle加密后的密码。
2.解密
在kettle里新建转换,拖入javascript组件,在里面写:
var setValue = org.pentaho.di.core.encryption.Encr.decryptPasswordOptionallyEncrypted('Encrypted 2be98afc86aa7f2e4cb79ce10bec3fd89');
3. 在javascript中对密码加密和解密
var encrypted_password = 'not encrypted';
加密(js中调用):
encrypted_password = "Encrypted " + Packages.org.pentaho.di.core.encryption.Encr.encryptPassword(clear_password);
解密:
if(value.startsWith("Encrypted ")){
setValue = org.pentaho.di.core.encryption.Encr.decryptPasswordOptionallyEncrypted(value);
}

浙公网安备 33010602011771号