println(hudson.util.Secret.fromString("1234").getEncryptedValue())
Output: {AQAAABAAAAAQc//GkWTtyO8B5f1re53AX+8S0yCRKA8h7ean+y/sQig=}
println(hudson.util.Secret.decrypt('{AQAAABAAAAAQc//GkWTtyO8B5f1re53AX+8S0yCRKA8h7ean+y/sQig=}'))
Output: 1234