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); }