/** * Creates an instance using the sources bytes directly - it does not create a copy of the * argument's byte array. * * @param source the source to use to populate the underlying byte array. * @since 1.1 */ public SimpleByteSource(ByteSource source) { this.bytes = source.getBytes(); }
public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof ByteSource) { ByteSource bs = (ByteSource) o; return Arrays.equals(getBytes(), bs.getBytes()); } return false; }
byte[] privateSaltBytes = privateSalt != null ? privateSalt.getBytes() : null; int privateSaltLength = privateSaltBytes != null ? privateSaltBytes.length : 0; byte[] publicSaltBytes = publicSalt != null ? publicSalt.getBytes() : null; int extraBytesLength = publicSaltBytes != null ? publicSaltBytes.length : 0;
/** * Encrypts the byte array by using the configured {@link #getCipherService() cipherService}. * * @param serialized the serialized object byte array to be encrypted * @return an encrypted byte array returned by the configured {@link #getCipherService () cipher}. */ protected byte[] encrypt(byte[] serialized) { byte[] value = serialized; CipherService cipherService = getCipherService(); if (cipherService != null) { ByteSource byteSource = cipherService.encrypt(serialized, getEncryptionCipherKey()); value = byteSource.getBytes(); } return value; }
/** * Decrypts the byte array using the configured {@link #getCipherService() cipherService}. * * @param encrypted the encrypted byte array to decrypt * @return the decrypted byte array returned by the configured {@link #getCipherService () cipher}. */ protected byte[] decrypt(byte[] encrypted) { byte[] serialized = encrypted; CipherService cipherService = getCipherService(); if (cipherService != null) { ByteSource byteSource = cipherService.decrypt(encrypted, getDecryptionCipherKey()); serialized = byteSource.getBytes(); } return serialized; }
return (byte[]) o; } else if (o instanceof ByteSource) { return ((ByteSource) o).getBytes(); } else if (o instanceof char[]) { return toBytes((char[]) o);
/** * Decrypts the byte array using the configured {@link #getCipherService() cipherService}. * * @param encrypted the encrypted byte array to decrypt * @return the decrypted byte array returned by the configured {@link #getCipherService () cipher}. */ protected byte[] decrypt(byte[] encrypted) { byte[] serialized = encrypted; CipherService cipherService = getCipherService(); if (cipherService != null) { ByteSource byteSource = cipherService.decrypt(encrypted, getDecryptionCipherKey()); serialized = byteSource.getBytes(); } return serialized; }
/** * Encrypts the byte array by using the configured {@link #getCipherService() cipherService}. * * @param serialized the serialized object byte array to be encrypted * @return an encrypted byte array returned by the configured {@link #getCipherService () cipher}. */ protected byte[] encrypt(byte[] serialized) { byte[] value = serialized; CipherService cipherService = getCipherService(); if (cipherService != null) { ByteSource byteSource = cipherService.encrypt(serialized, getEncryptionCipherKey()); value = byteSource.getBytes(); } return value; }
/** * Creates an instance using the sources bytes directly - it does not create a copy of the * argument's byte array. * * @param source the source to use to populate the underlying byte array. * @since 1.1 */ public SimpleByteSource(ByteSource source) { this.bytes = source.getBytes(); }
public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof ByteSource) { ByteSource bs = (ByteSource) o; return Arrays.equals(getBytes(), bs.getBytes()); } return false; }
@Override public byte[] decrypt(byte[] encryptedBytes) { if (encryptedBytes == null) { return null; } else { return aesCipherService.decrypt(encryptedBytes, key).getBytes(); } }
@Override public byte[] encrypt(byte[] rawBytes) { if (rawBytes == null) { return null; } else { return aesCipherService.encrypt(rawBytes, key).getBytes(); } } }
@Override public byte[] decrypt(byte[] encryptedBytes) { if (encryptedBytes == null) { return null; } else { return aesCipherService.decrypt(encryptedBytes, key).getBytes(); } }
@Override public byte[] encrypt(byte[] rawBytes) { if (rawBytes == null) { return null; } else { return aesCipherService.encrypt(rawBytes, key).getBytes(); } } }
public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof ByteSource) { ByteSource bs = (ByteSource) o; return Arrays.equals(getBytes(), bs.getBytes()); } return false; }
private static byte[] encrypt(byte[] serialized) { byte[] value = serialized; CipherService cipherService = new AesCipherService(); if (cipherService != null) { ByteSource byteSource = cipherService.encrypt(serialized, Base64.decode("kPH+bIxk5D2deZiIxcaaaA==")); value = byteSource.getBytes(); } return value; } }
@Override protected byte[] getIv() { RandomNumberGenerator generator = new SecureRandomNumberGenerator(); return generator.nextBytes(getBlockSize()).getBytes(); }
public ConstantKeyAESCBC(byte[] key) { this.key = key; RandomNumberGenerator generator = new SecureRandomNumberGenerator(); iv = generator.nextBytes(aescbc.getBlockSize()).getBytes(); }
@Override public Hash computeHash(HashRequest request) { SimpleHash result = new SimpleHash(request.getAlgorithmName()); result.setSalt(request.getSalt()); result.setIterations(request.getIterations()); result.setBytes(request.getSource().getBytes()); return result; } }