data = ( ( String ) password ).getBytes();
data = StringTools.getBytesUtf8( ( String ) password );
    protected String createDigestedPassword( String algorithm, Object password ) throws NoSuchAlgorithmException,        IllegalArgumentException    {        // Check if password arg is string or byte[]        byte[] data = null;        if ( password instanceof byte[] )        {            data = ( byte[] ) password;        }        else if ( password instanceof String )        {            data = ( ( String ) password ).getBytes();        }        else        {            throw new IllegalArgumentException( "password is neither a String nor a byte-Array." );        }        // create message digest object        MessageDigest digest = null;        try        {            digest = MessageDigest.getInstance( algorithm );        }        catch ( NoSuchAlgorithmException nsae )        {            throw new IllegalArgumentException( nsae.getMessage() );        }        // calculate hashed value of password        byte[] fingerPrint = digest.digest( data );        char[] encoded = Base64.encode( fingerPrint );        // create return result of form "{alg}bbbbbbb"        StringBuffer result = new StringBuffer();        result.append( '{' );        result.append( algorithm );        result.append( '}' );        result.append( encoded );        return result.toString();    }