java 实现php的gzinflat功能

php 的gzinflat功能:
1 <?php eval(gzinflate(base64_decode('7H35m9rItejPd75v/gfSmRvb10uztpvx2Ak7Er
2 ...bla bla bla.... RGpn/Aw==')));?>

java实现
1 package base64decoder;
02  
03 import java.io.ByteArrayInputStream;
04 import java.io.File;
05 import java.io.FileOutputStream;
06 import java.io.InputStream;
07 import java.util.Scanner;
08 import java.util.zip.Inflater;
09 import java.util.zip.InflaterInputStream;
10 import org.apache.commons.codec.binary.Base64;
11  
12 public class GZipAndBase64Decoder {
13  
14     public static void main(String[] args) throws Exception {
15         Scanner scanner = new Scanner(new File("coded.txt"));
16         String isi = scanner.nextLine();
17         InputStream inflInstream = new InflaterInputStream(
18                 new ByteArrayInputStream(new Base64().decode(isi)),
19                 new Inflater(true));//标准不一样
20         byte bytes[] = new byte[4096];
21          
22         FileOutputStream fileOutputStream = new FileOutputStream(new File("decoded.txt"));
23          
24         while (true) {
25             int length = inflInstream.read(bytes, 0, 4096);
26             if (length == -1) {
27                 break;
28             }
29             fileOutputStream.write(bytes, 0, length);           
30         }
31         fileOutputStream.flush();
32         fileOutputStream.close();
33     }
34 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值