CipherUtil { public static boolean isEncrypted(File file) throws IOException { byte[] actualMagic = new byte[MultiCipherOutputStream.STREAM_MAGIC.length]; RandomAccessFile rFile = new RandomAccessFile(file, "r"); rFile.read(actualMagic); rFile.close(); return Arrays.equals(actualMagic, MultiCipherOutputStream.STREAM_MAGIC); }  static synchronized void init(); static void enableUnlimitedStrength(); static byte[] createRandomArray(int size); static String createRandomAlphabeticString(int size); static SaltedSecretKey createDerivedKey(SecretKey inputKey, byte[] inputSalt, CipherSpec outputCipherSpec); static SaltedSecretKey createDerivedKey(byte[] inputKeyMaterial, byte[] inputSalt, String outputKeyAlgorithm, int outputKeySize); static SecretKey toSecretKey(byte[] secretKeyBytes, String algorithm); static SaltedSecretKey toSaltedSecretKey(byte[] secretKeyBytes, byte[] saltBytes, String algorithm); static SaltedSecretKey createMasterKey(String password); static SaltedSecretKey createMasterKey(String password, byte[] salt); static boolean isEncrypted(File file); static void encrypt(InputStream plaintextInputStream, OutputStream ciphertextOutputStream, List<CipherSpec> cipherSpecs,
			SaltedSecretKey masterKey); static byte[] encrypt(InputStream plaintextInputStream, List<CipherSpec> cipherSuites, SaltedSecretKey masterKey); static byte[] decrypt(InputStream fromInputStream, SaltedSecretKey masterKey); static KeyPair generateRsaKeyPair(); static X509Certificate generateSelfSignedCertificate(String commonName, KeyPair keyPair); static SSLContext createSSLContext(KeyStore keyStore, KeyStore trustStore);  }
@Test public void testIsEncryptedFileFalse() throws Exception { File tempDirectory = TestFileUtil.createTempDirectoryInSystemTemp(); File testFile = new File(tempDirectory+"/somefile"); TestFileUtil.writeToFile(new byte[] { 1, 2, 3 }, testFile); assertFalse(CipherUtil.isEncrypted(testFile)); TestFileUtil.deleteDirectory(tempDirectory); }
@Test public void testIsEncryptedFileTrue() throws Exception { File tempDirectory = TestFileUtil.createTempDirectoryInSystemTemp(); File testFile = new File(tempDirectory+"/somefile"); RandomAccessFile testFileRaf = new RandomAccessFile(testFile, "rw"); testFileRaf.write(MultiCipherOutputStream.STREAM_MAGIC); testFileRaf.write(MultiCipherOutputStream.STREAM_VERSION); testFileRaf.close(); assertTrue(CipherUtil.isEncrypted(testFile)); TestFileUtil.deleteDirectory(tempDirectory); }