使用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);
}
原文地址:https://www.cnblogs.com/rwxwsblog/p/4529078.html