@SuppressWarnings("checkstyle:MagicNumber")
    private static ByteSource getSalt(String saltString, String saltBytesString, boolean generateSalt, int generatedSaltSize) {

        if (saltString != null) {
            if (generateSalt || (saltBytesString != null)) {
                throw new IllegalArgumentException(SALT_MUTEX_MSG);
            }
            return ByteSource.Util.bytes(saltString);
        }

        if (saltBytesString != null) {
            if (generateSalt) {
                throw new IllegalArgumentException(SALT_MUTEX_MSG);
            }

            String value = saltBytesString;
            boolean base64 = true;
            if (saltBytesString.startsWith(HEX_PREFIX)) {
                //hex:
                base64 = false;
                value = value.substring(HEX_PREFIX.length());
            }
            byte[] bytes;
            if (base64) {
                bytes = Base64.decode(value);
            } else {
                bytes = Hex.decode(value);
            }
            return ByteSource.Util.bytes(bytes);
        }

        if (generateSalt) {
            SecureRandomNumberGenerator generator = new SecureRandomNumberGenerator();
            //generatedSaltSize is in *bits* - convert to byte size:
            int byteSize = generatedSaltSize / 8;
            return generator.nextBytes(byteSize);
        }

        //no salt used:
        return null;
    }
Commandline line utility to hash data such as strings, passwords, resources (files, urls, etc.).
<p/>
Usage:
<pre>
java -jar shiro-tools-hasher<em>-version</em>-cli.jar
</pre>
This will print out all supported options with documentation.

@since 1.2
tools/hasher/src/main/java/org/apache/shiro/tools/hasher/Hasher.java