2010-11-12 49 views
4

如果我想創建需要壓縮視頻的應用程序並且用戶必須使用密碼認證才能打開文件,可以嗎?Android zip文件認證

如果它是可能的,你們可以給我一些示例代碼嗎? 感謝, 問候

+7

我知道,英語不是你的母語,而是應該只是鼓勵你去證明你的問題。不是我們所有人都可能是同性戀,所以請給這些人重新說明一下。謝謝。 – 2010-11-12 08:17:37

回答

2

嘗試是這樣的:

OutputStream out = new ZipOutputStream(new CipherOutputStream(new FileOutputStream(...)), cipher); 

和周圍的其他方式:

InputStream in = new ZipInputStream(new CipherInputStream(new FileInputStream(...)), cipher); 

要創建密碼,請參閱:http://developer.android.com/reference/javax/crypto/Cipher.html

0

我不是確定你確實需要什麼,但是如果你想擁有密碼保護的zip文件,你可以使用this library: 下面是從那裏採取了一些代碼片段:

郵編:

ZipArchive zipArchive = new ZipArchive(); 
zipArchive.zip(targetPath,destinationPath,password); 

解壓:

ZipArchive zipArchive = new ZipArchive(); 
zipArchive.unzip(targetPath,destinationPath,password);