日常開發中,為了確保賬號和密碼的安全,時常要對密碼進行加密和解密。然而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); }