(String key, long revision)
| 784 | } |
| 785 | |
| 786 | private static byte[] getAd(String key, long revision) throws NoSuchAlgorithmException { |
| 787 | byte[] k = MessageDigest.getInstance("SHA256").digest(key.getBytes()); |
| 788 | byte[] ad = ByteBuffer.allocate(8 + 8) |
| 789 | .putLong(revision) // 8 bytes |
| 790 | .put(Arrays.copyOfRange(k, 0, 8)) |
| 791 | .array(); |
| 792 | return ad; |
| 793 | } |
| 794 | |
| 795 | private static String transform(String value, byte[] key, byte[] iv, byte[] ad, boolean encrypt) |
| 796 | throws InvalidCipherTextException, IOException { |