使用kettle轉換中的JavaScript對密碼進行加密和解密


日常開發中,為了確保賬號和密碼的安全,時常要對密碼進行加密和解密。然而kettle是怎么對密碼進行加密和解密的呢?

下面的代碼需要再轉換中的JavaScript中運行。

var encrypted_password = 'not encrypted';

加密(js中調用):
encrypted_password = "Encrypted " + Packages.org.pentaho.di.core.encryption.Encr.encryptPassword(clear_password);

命令行生成密碼:F:\pdi-open-3.1.0-826/Encr.bat

F:\pdi-open-3.1.0-826>encr -kettle abc
Encrypted 2be98afc86aa7f2e4cb79ce10be93add9
F:\pdi-open-3.1.0-826>

解密:
if(value.startsWith("Encrypted ")){
      setValue = org.pentaho.di.core.encryption.Encr.decryptPasswordOptionallyEncrypted(value);
}

 


免責聲明!

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



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