@Override
    public String toBase64() {
        if (this.base64Encoded == null) {
            //cache result in case this method is called multiple times.
            this.base64Encoded = Base64.encodeToString(getBytes());
        }
        return this.base64Encoded;
    }
Returns a Base64-encoded string of the underlying {@link #getBytes byte array}.
<p/>
This implementation caches the resulting Base64 string so multiple calls to this method remain efficient.
However, calling {@link #setBytes setBytes} will null the cached value, forcing it to be recalculated the
next time this method is called.

@return a Base64-encoded string of the underlying {@link #getBytes byte array}.
crypto/hash/src/main/java/org/apache/shiro/crypto/hash/SimpleHash.java