public static Bech32Data decode()

in src/main/java/org/openvasp/core/lnurl/Bech32.java [150:182]


    public static Bech32Data decode(final String str) throws IllegalArgumentException {
        boolean lower = false, upper = false;
        if (str.length() < 8)
            throw new IllegalArgumentException("Input too short: " + str.length());
        for (int i = 0; i < str.length(); ++i) {
            char c = str.charAt(i);
            if (c < 33 || c > 126) throw new IllegalArgumentException();
            if (c >= 'a' && c <= 'z') {
                if (upper)
                    throw new IllegalArgumentException();
                lower = true;
            }
            if (c >= 'A' && c <= 'Z') {
                if (lower)
                    throw new IllegalArgumentException();
                upper = true;
            }
        }
        final int pos = str.lastIndexOf('1');
        if (pos < 1) throw new IllegalArgumentException("Missing human-readable part");
        final int dataPartLength = str.length() - 1 - pos;
        if (dataPartLength < 6) throw new IllegalArgumentException("Data part too short: " + dataPartLength);
        byte[] values = new byte[dataPartLength];
        for (int i = 0; i < dataPartLength; ++i) {
            char c = str.charAt(i + pos + 1);
            if (CHARSET_REV[c] == -1) throw new IllegalArgumentException();
            values[i] = CHARSET_REV[c];
        }
        String hrp = str.substring(0, pos).toLowerCase(Locale.ROOT);
        Encoding encoding = verifyChecksum(hrp, values);
        if (encoding == null) throw new IllegalArgumentException();
        return new Bech32Data(encoding, hrp, Arrays.copyOfRange(values, 0, values.length - 6));
    }