Guava BaseEncoding - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava BaseEncoding class.

This code example shows how to use the following methods:encode
    byte[] hash = produceHash(salt, plaintextPassword);
 
    byte[] digest = new byte[salt.length + hash.length];
    System.arraycopy(salt, 0, digest, 0, salt.length);
    System.arraycopy(hash, 0, digest, salt.length, hash.length);
    return STRING_ENCODING.encode(digest);
  } 
 
  public boolean verifyPassword(String plaintextPassword, String digest) {
    if (digest.length() == LEGACY_SALT_LENGTH + HASH_LENGTH * 2) {
      return verifyLegacy(digest, plaintextPassword);
    } 
 
    byte[] digestBytes = STRING_ENCODING.decode(digest);
    byte[] salt = new byte[digestBytes.length - HASH_LENGTH];
    System.arraycopy(digestBytes, 0, salt, 0, salt.length);
    byte[] providedHash = new byte[HASH_LENGTH];
    System.arraycopy(digestBytes, salt.length, providedHash, 0, providedHash.length);
 
    byte[] expectedHash = produceHash(salt, plaintextPassword);
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:decode
	public static byte[] decryptBytes(@Nonnull final String textToDecode, @Nonnull final char[] password) throws IOException
	{ 
		final byte[] decodeTextAsBytes;
		try 
		{ 
			decodeTextAsBytes = BASE64_DECRYPT.decode(textToDecode);
		} 
		catch (final IllegalArgumentException x)
		{ 
			throw new IOException("invalid base64 encoding");
		} 
 
		if (decodeTextAsBytes.length < OPENSSL_SALTED_BYTES.length)
			throw new IOException("out of salt");
 
		final byte[] cipherBytes = new byte[decodeTextAsBytes.length - OPENSSL_SALTED_BYTES.length];
		System.arraycopy(decodeTextAsBytes, OPENSSL_SALTED_BYTES.length, cipherBytes, 0, decodeTextAsBytes.length - OPENSSL_SALTED_BYTES.length);
 
		final byte[] decryptedBytes = decryptRaw(cipherBytes, password);
 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Guava BaseEncoding Methods: