private void checkAndSetSalt(final String salt) { if (TextUtils.isEmpty(salt)) { this.salt = CryptoHelper.getRandomBytes(AESCrypto.SALT_SIZE_DEFAULT); } else { this.salt = CryptoHelper.getRawBytes(salt); } }
public static String encrypt( final String text, final String password, final byte[] salt, final byte[] iv) { final byte[] data = CryptoHelper.getRawBytes(text); final byte[] encryptedData = AES.encrypt(data, password, salt, iv, AES.KEY_SIZE_DEFAULT, AES.ITERATION_COUNT_DEFAULT); return CryptoHelper.base64Encode(encryptedData); }
private void checkAndSetPassword(final String password) { if (TextUtils.isEmpty(password)) { this.password = CryptoHelper.getRandomString(); } else { this.password = password; } }
public static String sha256(final String text) { return new String(HASH.encodeHex(HASH.sha256Bytes(CryptoHelper.getRawBytes(text)))); }
public String encrypt(final String text) { final byte[] data = CryptoHelper.getRawBytes(text); final byte[] encryptedData = encrypt(data); return CryptoHelper.base64Encode(encryptedData); }
public String decrypt(final String text) { final byte[] encryptedData = CryptoHelper.base64Decode(text); final byte[] data = decrypt(encryptedData); return CryptoHelper.getString(data); }
private void checkAndSetIV() { this.iv = CryptoHelper.getRandomBytes(AESCrypto.IV_SIZE_DEFAULT); }