0
파일 암호화 및 암호 해독 앱을 개발 중이며 파일 암호화 및 암호 해독의 진행률 막대를 약간 보여줍니다. 진행률 표시 줄을 구현해야합니다. 어떻게해야합니까? 아래 코드를 참조하십시오.android에서 진행률 표시 줄 구현
public void main(String[] args) throws Exception
{
// File to decrypt.
filename = "/file.enc";
String password = "codecodecode";
inFile = new FileInputStream(new File(Environment.getExternalStorageDirectory()+ filename));
outFile = new FileOutputStream(new File(Environment.getExternalStorageDirectory()+ filename + ".txt"));
PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray());
SecretKeyFactory keyFactory =
SecretKeyFactory.getInstance("PBEWithMD5AndDES");
SecretKey passwordKey = keyFactory.generateSecret(keySpec);
// Read in the previouly stored salt and set the iteration count.
byte[] salt = new byte[8];
inFile.read(salt);
int iterations = 100;
PBEParameterSpec parameterSpec = new PBEParameterSpec(salt, iterations);
// Create the cipher and initialize it for decryption.
Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
cipher.init(Cipher.DECRYPT_MODE, passwordKey, parameterSpec);
byte[] input = new byte[64];
int bytesRead;
while ((bytesRead = inFile.read(input)) != -1)
{
byte[] output = cipher.update(input, 0, bytesRead);
if (output != null)
outFile.write(output);
}
byte[] output = cipher.doFinal();
if (output != null)
outFile.write(output);
inFile.close();
outFile.flush();
outFile.close();
}