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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM