트리플 데스를 사용하여 android에서 파일을 암호화했습니다. 이 파일은 PHP를 사용하여 서버에 업로드됩니다. 동일한 파일의 암호를 해독하는 PHP 스크립트를 작성해야합니다.android에서 암호화 된 파일의 암호를 해독하십시오.
PHP를 처음 접한다면, PHP 스크립트를 통해 도움을 얻을 수 있습니다.
public void encrypt(InputStream in, OutputStream out) throws Exception {
final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
final IvParameterSpec param = new IvParameterSpec(iv);
final Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key, param);
// Read in the cleartext bytes and write to out to encrypt
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
byte[] output = cipher.doFinal(buf, 0, numRead);
if(output != null) {
byte[] enc = Base64.encode(output, 0);
out.write(enc);
}
}
out.close();
}
나는 keyBytes
16 진수 값입니다 iv
하드 코딩 된 값을 전달하고있다.
스택 오버플로에 오신 것을 환영합니다. [How to Ask] (http://stackoverflow.com/questions/how-to-ask), [무엇을 시도 했습니까?] (http://mattgemmell.com/2008/12/08/what-have -you-tried /), [질문하는 방법 (Smart Way)] (http://catb.org/esr/faqs/smart-questions.html). –