private boolean dumpKey(final byte[] key) throws Exception {
    byte[] encoded = Base64.encodeBase64Chunked(key);
    String encText = new String(encoded);

    System.out.println("Copy the text between the delimiters");
    System.out.println("Take all below this line ----------------------->");
    System.out.println(encText);
    System.out.println("<--------------- up to and not including this line");

    // See if it decodes
    byte[] decoded = Base64.encodeBase64Chunked(encText.getBytes());

    if (decoded.length != key.length) {
      error("Validity check failed: lengths not equal " +
           "(decoded=" + decoded.length + " key=" + key.length + ")");
      dumpHex(decoded);
      error(" ");
      dumpHex(key);
      return false;
    }

    for (int i = 0; i < decoded.length; i++) {
      if (decoded[i] != key[i]) {
        error("Validity check failed: byte at position " + i + " not equal");
        dumpHex(decoded);
        error(" ");
        dumpHex(key);

        return false;
      }
    }

    return true;
  }
private boolean dumpKey ( final byte [ ] key ) throws Exception { byte [ ] encoded = Base64 . encodeBase64Chunked ( key ) ; String encText = new String ( encoded ) ; System . out . println ( "Copy the text between the delimiters" ) ; System . out . println ( "Take all below this line ----------------------->" ) ; System . out . println ( encText ) ; System . out . println ( "<--------------- up to and not including this line" ) ; byte [ ] decoded = Base64 . encodeBase64Chunked ( encText . getBytes ( ) ) ; if ( decoded . length != key . length ) { error ( "Validity check failed: lengths not equal " + "(decoded=" + decoded . length + " key=" + key . length + ")" ) ; dumpHex ( decoded ) ; error ( " " ) ; dumpHex ( key ) ; return false ; } for ( int i = 0 ; i < decoded . length ; i ++ ) { if ( decoded [ i ] != key [ i ] ) { error ( "Validity check failed: byte at position " + i + " not equal" ) ; dumpHex ( decoded ) ; error ( " " ) ; dumpHex ( key ) ; return false ; } } return true ; }
Dump a byte array as a base 64 encoded value. We also check that the
form we emit can be decoded and produce an identical key.
<p>
We then go on to encode and decode our testText to see if they match.

@param key
@return boolean
@throws Exception