@@ -0,0 +1,1763 @@
+/*%0A * jPOS Project %5Bhttp://jpos.org%5D%0A * Copyright (C) 2000-2020 jPOS Software SRL%0A *%0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as%0A * published by the Free Software Foundation, either version 3 of the%0A * License, or (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU Affero General Public License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage org.jpos.q2.cli;%0A%0Aimport org.jpos.iso.ISOUtil;%0Aimport org.jpos.q2.CLICommand;%0Aimport org.jpos.q2.CLIContext;%0Aimport org.jpos.security.SystemSeed;%0A%0Aimport java.nio.ByteBuffer;%0Aimport java.security.SecureRandom;%0Aimport java.util.Base64;%0A%0A/**%0A * Obfuscate a secret%0A */%0Apublic class OBF implements CLICommand %7B%0A    @Override%0A    public void exec(CLIContext cli, String%5B%5D args) throws Exception %7B%0A        if (args.length != 2) %7B%0A            usage(cli);%0A            return;%0A        %7D%0A        cli.println (String.format(%22obf:%25s%22, obf(args%5B1%5D)));%0A    %7D%0A    public void usage(CLIContext cli) %7B%0A        cli.println(%22Usage: obf %5C%22secret%5C%22%22);%0A    %7D%0A%0A    private String obf(String s) %7B%0A        byte%5B%5D b = s.getBytes();%0A        int i = Math.abs(new SecureRandom().nextInt());%0A        b = ISOUtil.xor(b, SystemSeed.getSeed(i, b.length));%0A        ByteBuffer buf = ByteBuffer.allocate(b.length + 8);%0A        buf.putInt(i);%0A        buf.put(b);%0A        return Base64.getEncoder().encodeToString(buf.array());%0A    %7D%0A%7D%0A

Add OBF command