私はtriple desを使ってアンドロイドでファイルを暗号化しました。このファイルはPHPを使用してサーバーにアップロードされます。同じファイルを解読するためのPHPスクリプトを書かなければならない。androidで暗号化されたphpのファイルを解読する
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();
}
私は、16進値でありkeyBytes
とiv
用のハードコードされた値を渡しています。
ようこそスタックオーバーフロー。 [How to Ask](http://stackoverflow.com/questions/how-to-ask)、[何を試しましたか?](http://mattgemmell.com/2008/12/08/what-have 「〜を試してみよう」、「[スマートウェイに質問する方法]」(http://catb.org/esr/faqs/smart-questions.html)を参照してください。 –