[英]Decrypt a file in php which is encrypted in android
我使用三重des在android中加密了文件。 此文件使用php上傳到服務器。 必須編寫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();
}
我正在傳遞keyBytes
和iv
硬編碼值,它們是十六進制值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.