精华内容
下载资源
问答
  • PNG 转十六进制 轻松将 PNG 图像转换为十六进制值批次。 什么 该模块可能是 npm 模块的 Google Plus,但对于某些小型硬件项目、显示测试等可能非常有用。 在使用裸露的低级硬件时,我们有时希望或需要显示复杂的像素...
  • 将TCP接收到的十六进制字符串 如 “FF D8 FF E0 00 10 4A……CE 78 E9 4D DC A3 FF D9”,这样的图片数据,转换成python-opencv 或者numpy 可以读取的数据 并可以显示出来
  • 图片数据成16进制数据工具,内有详细说明文档,1、 运行WinHex.exe 2、 复制的时候选择这个即可
  • 解析 png 图片十六进制字符流

    千次阅读 2011-06-06 11:24:00
    uses pngimage;{从 png 图片十六进制字符串}function Png2Hex(png: TPngImage): string;var stream: TMemoryStream;begin stream := TMemoryStream.Create; png.SaveToStream(stream); SetLength(Resul

     

     

    http://www.cnblogs.com/del/archive/2011/01/17/1937547.html  转自

    展开全文
  • //形成十六进制最后存储的txt文件 //得到数据流的长度 int length = (int)fs.Length; sw.WriteLine("#include "); sw.WriteLine("const unsigned char gImage_m"+i+"[] PROGMEM = {"); while (length > 0) { byte ...

    ******************************点我下载@@@@@@@@@@@@@@@@@@@@

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace jpgTo16
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                textBox1.Text = @"E:\D盘数据\draft\EleTVtest";
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                String[] fileNames = Directory.GetFiles(textBox1.Text);
                List<string> jpgNames = new List<string>();
    
    
    
                foreach (var item in fileNames)
                {
                    if (item.EndsWith(".jpg"))
                    {
                        string jpgName = Path.GetFileName(item);
                        richTextBox1.Text += jpgName + "\n";
                        jpgNames.Add(jpgName);
    
                    }
                }
                StreamWriter sw = new StreamWriter(textBox1.Text + @"\" + "time.h");
                for (int i = 0; i < jpgNames.Count(); i++)
                {
                    //从文件目录中将图片读入到IO流中
                    FileStream fs = new FileStream(textBox1.Text+@"\"+ jpgNames[i], FileMode.Open, FileAccess.Read);
                    //对数据流进行编码八位二进制
                    BinaryReader br = new BinaryReader(fs);
                    //形成十六进制最后存储的txt文件
                   
                    //得到数据流的长度
                    int length = (int)fs.Length;
    
                    sw.WriteLine("#include <pgmspace.h>");
    
                    sw.WriteLine("const unsigned char gImage_m"+i+"[] PROGMEM = {");
    
                    while (length > 0)
                    {
                        byte tempByte = br.ReadByte();
                        //将八位二进制转换为十六进制字符串形式
                        string tempStr = "0X";
    
                        tempStr += Convert.ToString(tempByte, 16);
    
                        tempStr += ",";
    
                        //写入txt
                        sw.WriteLine(tempStr);
                        length--;
                    }
    
                    sw.WriteLine("};");
                    //关闭IO流释放资源
                    fs.Close();
                    br.Close();
    
                }
    
    
                sw.Close();
                MessageBox.Show("转换完成");
    
    
            }
        }
    }
    
    

    在这里插入图片描述
    使用教程:

    1. 将所有图片保存在一个文件夹中
    2. 在地址栏填入文件夹中
    3. 点击按键
    4. 里面的所有jpg文件按顺序将会转换成数组保存在一个.h文件里
    5. 直接引用头文件,使用里面的数组即可显示图片

    演示
    在这里插入图片描述

    展开全文
  • 首先使用十六进制器打开微信dat文件,显示如下 jpg图片文件头一般为FF D8 开头的,所以此处使用科学计算器,计算异或值 计算后的值 所以此处异或值就是0x9D 代码 以下是java代码,创建一个...
    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
    本文链接: https://blog.csdn.net/a627428179/article/details/95485146

    前言

    偶然看到有可以解密微信dat的文档,上网查了查,找到了一篇可以用的文章,不过转换过程代码是有问题的,在这里改了下发布上来。
    附带依赖jdk8的微信图片破解小工具:链接:https://pan.baidu.com/s/1t_e5rMFKmIRDNQAfN5rtaQ
    提取码:ymw6

    关于异或值怎么计算

    首先使用十六进制器打开微信dat文件,显示如下
    微信dat文件
    jpg图片文件头一般为FF D8 开头的,所以此处使用科学计算器,计算异或值
    在这里插入图片描述
    在这里插入图片描述
    计算后的值
    在这里插入图片描述
    所以此处异或值就是0x9D

    代码

    以下是java代码,创建一个weChatImgRevert .class后复制进去就好啦。
    此处的jdk版本需要1.8以上…,另外三个参数需要改成自己的哦~

    package main.java.com.example.demo;
    

    import java.io.*;
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.concurrent.atomic.AtomicReference;

    public class weChatImgRevert {

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span>String<span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        String path <span class="token operator">=</span> <span class="token string">"C:\\Users\\Administrator\\Documents\\WeChat Files\\xxx\\FileStorage\\Image\\2019-07"</span><span class="token punctuation">;</span>
        String targetPath <span class="token operator">=</span> <span class="token string">"D:\\weChat\\2019-07\\"</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> xor <span class="token operator">=</span> <span class="token number">0xCB</span><span class="token punctuation">;</span>
        <span class="token function">convert</span><span class="token punctuation">(</span>path<span class="token punctuation">,</span> targetPath<span class="token punctuation">,</span> xor<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token comment">/**
     * @param path       图片地址
     * @param targetPath 转换后目录
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">convert</span><span class="token punctuation">(</span>String path<span class="token punctuation">,</span> String targetPath<span class="token punctuation">,</span> <span class="token keyword">int</span> xor<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        File<span class="token punctuation">[</span><span class="token punctuation">]</span> file <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>path<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">listFiles</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>file <span class="token operator">==</span> null<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">int</span> size <span class="token operator">=</span> file<span class="token punctuation">.</span>length<span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">"总共"</span> <span class="token operator">+</span> size <span class="token operator">+</span> <span class="token string">"个文件"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        AtomicReference<span class="token generics function"><span class="token punctuation">&lt;</span>Integer<span class="token punctuation">&gt;</span></span> integer <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">AtomicReference</span><span class="token operator">&lt;</span><span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        Arrays<span class="token punctuation">.</span><span class="token function">stream</span><span class="token punctuation">(</span>file<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">parallel</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">forEach</span><span class="token punctuation">(</span>file1 <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token punctuation">{</span>
            <span class="token keyword">try</span> <span class="token punctuation">(</span>InputStream reader <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FileInputStream</span><span class="token punctuation">(</span>file1<span class="token punctuation">)</span><span class="token punctuation">;</span>
                 OutputStream writer <span class="token operator">=</span>
                         <span class="token keyword">new</span> <span class="token class-name">FileOutputStream</span><span class="token punctuation">(</span>targetPath <span class="token operator">+</span> file1<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"\\."</span><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">+</span> <span class="token string">".jpg"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> bytes <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">byte</span><span class="token punctuation">[</span><span class="token number">1024</span> <span class="token operator">*</span> <span class="token number">10</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
                <span class="token keyword">int</span> b<span class="token punctuation">;</span>
                <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>b <span class="token operator">=</span> reader<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>bytes<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token comment">//这里的in.read(bytes);就是把输入流中的东西,写入到内存中(bytes)。</span>
                    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> bytes<span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                        bytes<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span> <span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span> <span class="token punctuation">(</span>bytes<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">^</span> xor<span class="token punctuation">)</span><span class="token punctuation">;</span>
                        <span class="token keyword">if</span> <span class="token punctuation">(</span>i <span class="token operator">==</span> <span class="token punctuation">(</span>b <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                            <span class="token keyword">break</span><span class="token punctuation">;</span>
                        <span class="token punctuation">}</span>
                    <span class="token punctuation">}</span>
                    writer<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>bytes<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> b<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    writer<span class="token punctuation">.</span><span class="token function">flush</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                integer<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span>integer<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>file1<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"(大小:"</span> <span class="token operator">+</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">double</span><span class="token punctuation">)</span> file1<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">/</span> <span class="token number">1000</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"kb),进度:"</span> <span class="token operator">+</span> integer<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span>
                        <span class="token string">"/"</span> <span class="token operator">+</span> size<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">Exception</span> e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">"解析完毕!"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token comment">/**
     * 获取异或值,不一定准确,当解析不出来的时候,换一张图片的异或值来解析
     *
     * @param PhotoPath
     * @return
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">int</span> <span class="token function">getXor</span><span class="token punctuation">(</span>String PhotoPath<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        File file <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>PhotoPath<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">try</span> <span class="token punctuation">(</span>InputStream reader <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FileInputStream</span><span class="token punctuation">(</span>file<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> xors <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">int</span><span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            xors<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">=</span> reader<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&amp;</span> <span class="token number">0xFF</span> <span class="token operator">^</span> <span class="token number">0xFF</span><span class="token punctuation">;</span>
            xors<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">=</span> reader<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&amp;</span> <span class="token number">0xFF</span> <span class="token operator">^</span> <span class="token number">0xD8</span><span class="token punctuation">;</span>
            reader<span class="token punctuation">.</span><span class="token function">skip</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            xors<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span> <span class="token operator">=</span> reader<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&amp;</span> <span class="token number">0xFF</span> <span class="token operator">^</span> <span class="token number">0xFF</span><span class="token punctuation">;</span>
            xors<span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span> <span class="token operator">=</span> reader<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&amp;</span> <span class="token number">0xFF</span> <span class="token operator">^</span> <span class="token number">0xD9</span><span class="token punctuation">;</span>
            Map<span class="token generics function"><span class="token punctuation">&lt;</span>Integer<span class="token punctuation">,</span> Integer<span class="token punctuation">&gt;</span></span> map <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token operator">&lt;</span><span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> xor <span class="token operator">:</span> xors<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>map<span class="token punctuation">.</span><span class="token function">containsKey</span><span class="token punctuation">(</span>xor<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    map<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span>xor<span class="token punctuation">,</span> map<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>xor<span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
                    map<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span>xor<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> map<span class="token punctuation">.</span><span class="token function">values</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">stream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">max</span><span class="token punctuation">(</span>Integer<span class="token operator">:</span><span class="token operator">:</span>compareTo<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">Exception</span> e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    

    }

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86

    执行main方法后就可以在目标文件夹中去看转换后的图片了
    以下是转换后的效果图片: 效果图

    第二种方式,适合不懂怎么计算,想直接用的代码

    以下是java代码,创建一个WxChatImgRevert.class后复制进去就好啦。
    此处的jdk版本需要1.8以上…,另外两个参数需要改成自己的哦~
    此处的原理是判断图片文件的十六进制特征码。

    package main.java.com.example.demo;
    

    import java.io.*;
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.concurrent.atomic.AtomicInteger;
    import java.util.concurrent.atomic.AtomicReference;

    public class WxChatImgRevert2 {

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span>String<span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        String path <span class="token operator">=</span> <span class="token string">"C:\\Users\\Administrator\\Documents\\WeChat Files\\xxx\\FileStorage"</span><span class="token punctuation">;</span>
        String targetPath <span class="token operator">=</span> <span class="token string">"D:\\weChat\\temp"</span><span class="token punctuation">;</span>
        <span class="token function">convert</span><span class="token punctuation">(</span>path<span class="token punctuation">,</span> targetPath<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token comment">/**
     * @param path       图片目录地址
     * @param targetPath 转换后目录
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">convert</span><span class="token punctuation">(</span>String path<span class="token punctuation">,</span> String targetPath<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        File<span class="token punctuation">[</span><span class="token punctuation">]</span> file <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>path<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">listFiles</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>file <span class="token operator">==</span> null<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">int</span> size <span class="token operator">=</span> file<span class="token punctuation">.</span>length<span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">"总共"</span> <span class="token operator">+</span> size <span class="token operator">+</span> <span class="token string">"个文件"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        AtomicReference<span class="token generics function"><span class="token punctuation">&lt;</span>Integer<span class="token punctuation">&gt;</span></span> integer <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">AtomicReference</span><span class="token operator">&lt;</span><span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        AtomicInteger x <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">AtomicInteger</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span>File file1 <span class="token operator">:</span> file<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>file1<span class="token punctuation">.</span><span class="token function">isFile</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                Object<span class="token punctuation">[</span><span class="token punctuation">]</span> xori <span class="token operator">=</span> <span class="token function">getXor</span><span class="token punctuation">(</span>file1<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>xori <span class="token operator">!=</span> null <span class="token operator">&amp;&amp;</span> xori<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">!=</span> null<span class="token punctuation">)</span><span class="token punctuation">{</span>
                    x<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span>xori<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token keyword">break</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        Arrays<span class="token punctuation">.</span><span class="token function">stream</span><span class="token punctuation">(</span>file<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">parallel</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">forEach</span><span class="token punctuation">(</span>file1 <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>file1<span class="token punctuation">.</span><span class="token function">isDirectory</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                String<span class="token punctuation">[</span><span class="token punctuation">]</span> newTargetPath <span class="token operator">=</span> file1<span class="token punctuation">.</span><span class="token function">getPath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"/|\\\\"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                File targetFile <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>targetPath<span class="token operator">+</span>File<span class="token punctuation">.</span>separator<span class="token operator">+</span>newTargetPath<span class="token punctuation">[</span>newTargetPath<span class="token punctuation">.</span>length <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>targetFile<span class="token punctuation">.</span><span class="token function">exists</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    targetFile<span class="token punctuation">.</span><span class="token function">mkdirs</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token function">convert</span><span class="token punctuation">(</span>file1<span class="token punctuation">.</span><span class="token function">getPath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>targetPath<span class="token operator">+</span>File<span class="token punctuation">.</span>separator<span class="token operator">+</span>newTargetPath<span class="token punctuation">[</span>newTargetPath<span class="token punctuation">.</span>length <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">return</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            Object<span class="token punctuation">[</span><span class="token punctuation">]</span> xor <span class="token operator">=</span> <span class="token function">getXor</span><span class="token punctuation">(</span>file1<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>x<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span> <span class="token operator">&amp;&amp;</span> xor<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">!=</span> null <span class="token operator">&amp;&amp;</span> <span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span> xor<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                x<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span> xor<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            xor<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">=</span> xor<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">==</span> null <span class="token operator">?</span> x<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">:</span> xor<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            <span class="token keyword">try</span> <span class="token punctuation">(</span>InputStream reader <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FileInputStream</span><span class="token punctuation">(</span>file1<span class="token punctuation">)</span><span class="token punctuation">;</span>
                 OutputStream writer <span class="token operator">=</span>
                         <span class="token keyword">new</span> <span class="token class-name">FileOutputStream</span><span class="token punctuation">(</span>targetPath <span class="token operator">+</span> File<span class="token punctuation">.</span>separator <span class="token operator">+</span> file1<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"\\."</span><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">+</span> <span class="token punctuation">(</span>xor<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">!=</span> null <span class="token operator">?</span>
                                 <span class="token string">"."</span> <span class="token operator">+</span> xor<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> bytes <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">byte</span><span class="token punctuation">[</span><span class="token number">1024</span> <span class="token operator">*</span> <span class="token number">10</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
                <span class="token keyword">int</span> b<span class="token punctuation">;</span>
                <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>b <span class="token operator">=</span> reader<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>bytes<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token comment">//这里的in.read(bytes);就是把输入流中的东西,写入到内存中(bytes)。</span>
                    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> bytes<span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                        bytes<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span> <span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span> <span class="token punctuation">(</span>bytes<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">^</span> <span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span> xor<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                        <span class="token keyword">if</span> <span class="token punctuation">(</span>i <span class="token operator">==</span> <span class="token punctuation">(</span>b <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                            <span class="token keyword">break</span><span class="token punctuation">;</span>
                        <span class="token punctuation">}</span>
                    <span class="token punctuation">}</span>
                    writer<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>bytes<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> b<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    writer<span class="token punctuation">.</span><span class="token function">flush</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                integer<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span>integer<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>file1<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"(大小:"</span> <span class="token operator">+</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">double</span><span class="token punctuation">)</span> file1<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">/</span> <span class="token number">1000</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"kb,异或值:"</span> <span class="token operator">+</span> xor<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">+</span> <span class="token string">"),"</span> <span class="token operator">+</span>
                        <span class="token string">"进度:"</span> <span class="token operator">+</span> integer<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span>
                        <span class="token string">"/"</span> <span class="token operator">+</span> size<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">Exception</span> e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">"解析完毕!"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token comment">/**
     * 判断图片异或值
     *
     * @param file
     * @return
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> Object<span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">getXor</span><span class="token punctuation">(</span>File file<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        Object<span class="token punctuation">[</span><span class="token punctuation">]</span> xor <span class="token operator">=</span> null<span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>file <span class="token operator">!=</span> null<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> bytes <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">byte</span><span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            <span class="token keyword">try</span> <span class="token punctuation">(</span>InputStream reader <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FileInputStream</span><span class="token punctuation">(</span>file<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                reader<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>bytes<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> bytes<span class="token punctuation">.</span>length<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">Exception</span> e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            xor <span class="token operator">=</span> <span class="token function">getXor</span><span class="token punctuation">(</span>bytes<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> xor<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token comment">/**
     * @param bytes
     * @return
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> Object<span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">getXor</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> bytes<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        Object<span class="token punctuation">[</span><span class="token punctuation">]</span> xorType <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> xors <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">int</span><span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span>Map<span class="token punctuation">.</span>Entry<span class="token generics function"><span class="token punctuation">&lt;</span>String<span class="token punctuation">,</span> String<span class="token punctuation">&gt;</span></span> type <span class="token operator">:</span> FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">entrySet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            String<span class="token punctuation">[</span><span class="token punctuation">]</span> hex <span class="token operator">=</span> <span class="token punctuation">{</span>
                    String<span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>type<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">charAt</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">+</span> type<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">charAt</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                    String<span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>type<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">charAt</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">+</span> type<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">charAt</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                    String<span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>type<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">charAt</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">+</span> type<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">charAt</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span>
            <span class="token punctuation">}</span><span class="token punctuation">;</span>
            xors<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">=</span> bytes<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">&amp;</span> <span class="token number">0xFF</span> <span class="token operator">^</span> Integer<span class="token punctuation">.</span><span class="token function">parseInt</span><span class="token punctuation">(</span>hex<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            xors<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">=</span> bytes<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">&amp;</span> <span class="token number">0xFF</span> <span class="token operator">^</span> Integer<span class="token punctuation">.</span><span class="token function">parseInt</span><span class="token punctuation">(</span>hex<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            xors<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span> <span class="token operator">=</span> bytes<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span> <span class="token operator">&amp;</span> <span class="token number">0xFF</span> <span class="token operator">^</span> Integer<span class="token punctuation">.</span><span class="token function">parseInt</span><span class="token punctuation">(</span>hex<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>xors<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">==</span> xors<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">&amp;&amp;</span> xors<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">==</span> xors<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                xorType<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">=</span> type<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                xorType<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">=</span> xors<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
                <span class="token keyword">break</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> xorType<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">static</span> Map<span class="token generics function"><span class="token punctuation">&lt;</span>String<span class="token punctuation">,</span> String<span class="token punctuation">&gt;</span></span> FILE_TYPE_MAP <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics function"><span class="token punctuation">&lt;</span>String<span class="token punctuation">,</span> String<span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    
    <span class="token keyword">static</span> <span class="token punctuation">{</span>
        <span class="token function">getAllFileType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">getAllFileType</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"ffd8ffe000104a464946"</span><span class="token punctuation">,</span> <span class="token string">"jpg"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//JPEG (jpg)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"89504e470d0a1a0a0000"</span><span class="token punctuation">,</span> <span class="token string">"png"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//PNG (png)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"47494638396126026f01"</span><span class="token punctuation">,</span> <span class="token string">"gif"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//GIF (gif)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"49492a00227105008037"</span><span class="token punctuation">,</span> <span class="token string">"tif"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//TIFF (tif)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"424d228c010000000000"</span><span class="token punctuation">,</span> <span class="token string">"bmp"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//16色位图(bmp)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"424d8240090000000000"</span><span class="token punctuation">,</span> <span class="token string">"bmp"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//24位位图(bmp)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"424d8e1b030000000000"</span><span class="token punctuation">,</span> <span class="token string">"bmp"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//256色位图(bmp)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"41433130313500000000"</span><span class="token punctuation">,</span> <span class="token string">"dwg"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//CAD (dwg)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"3c21444f435459504520"</span><span class="token punctuation">,</span> <span class="token string">"html"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//HTML (html)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"3c21646f637479706520"</span><span class="token punctuation">,</span> <span class="token string">"htm"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//HTM (htm)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"48544d4c207b0d0a0942"</span><span class="token punctuation">,</span> <span class="token string">"css"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//css</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"696b2e71623d696b2e71"</span><span class="token punctuation">,</span> <span class="token string">"js"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//js</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"7b5c727466315c616e73"</span><span class="token punctuation">,</span> <span class="token string">"rtf"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Rich Text Format (rtf)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"38425053000100000000"</span><span class="token punctuation">,</span> <span class="token string">"psd"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Photoshop (psd)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"46726f6d3a203d3f6762"</span><span class="token punctuation">,</span> <span class="token string">"eml"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Email [Outlook Express 6] (eml)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"d0cf11e0a1b11ae10000"</span><span class="token punctuation">,</span> <span class="token string">"doc"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//MS Excel 注意:word、msi 和 excel的文件头一样</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"d0cf11e0a1b11ae10000"</span><span class="token punctuation">,</span> <span class="token string">"vsd"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Visio 绘图</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"5374616E64617264204A"</span><span class="token punctuation">,</span> <span class="token string">"mdb"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//MS Access (mdb)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"252150532D41646F6265"</span><span class="token punctuation">,</span> <span class="token string">"ps"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"255044462d312e360d25"</span><span class="token punctuation">,</span> <span class="token string">"pdf"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Adobe Acrobat (pdf)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"2e524d46000000120001"</span><span class="token punctuation">,</span> <span class="token string">"rmvb"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//rmvb/rm相同</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"464c5601050000000900"</span><span class="token punctuation">,</span> <span class="token string">"flv"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//flv与f4v相同</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"00000020667479706973"</span><span class="token punctuation">,</span> <span class="token string">"mp4"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"49443303000000000f76"</span><span class="token punctuation">,</span> <span class="token string">"mp3"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"000001ba210001000180"</span><span class="token punctuation">,</span> <span class="token string">"mpg"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"3026b2758e66cf11a6d9"</span><span class="token punctuation">,</span> <span class="token string">"wmv"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//wmv与asf相同</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"524946464694c9015741"</span><span class="token punctuation">,</span> <span class="token string">"wav"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Wave (wav)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"52494646d07d60074156"</span><span class="token punctuation">,</span> <span class="token string">"avi"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"4d546864000000060001"</span><span class="token punctuation">,</span> <span class="token string">"mid"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//MIDI (mid)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"504b0304140000000800"</span><span class="token punctuation">,</span> <span class="token string">"zip"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"526172211a0700cf9073"</span><span class="token punctuation">,</span> <span class="token string">"rar"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"235468697320636f6e66"</span><span class="token punctuation">,</span> <span class="token string">"ini"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"504b03040a0000000000"</span><span class="token punctuation">,</span> <span class="token string">"jar"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"4d5a9000030000000400"</span><span class="token punctuation">,</span> <span class="token string">"exe"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//可执行文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"3c25402070616765206c"</span><span class="token punctuation">,</span> <span class="token string">"jsp"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//jsp文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"4d616e69666573742d56"</span><span class="token punctuation">,</span> <span class="token string">"mf"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//MF文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"3c3f786d6c2076657273"</span><span class="token punctuation">,</span> <span class="token string">"xml"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//xml文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"efbbbf2f2a0d0a53514c"</span><span class="token punctuation">,</span> <span class="token string">"sql"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//xml文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"7061636b616765207765"</span><span class="token punctuation">,</span> <span class="token string">"java"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//java文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"406563686f206f66660d"</span><span class="token punctuation">,</span> <span class="token string">"bat"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//bat文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"1f8b0800000000000000"</span><span class="token punctuation">,</span> <span class="token string">"gz"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//gz文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"6c6f67346a2e726f6f74"</span><span class="token punctuation">,</span> <span class="token string">"properties"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//bat文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"cafebabe0000002e0041"</span><span class="token punctuation">,</span> <span class="token string">"class"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//bat文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"49545346030000006000"</span><span class="token punctuation">,</span> <span class="token string">"chm"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//bat文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"04000000010000001300"</span><span class="token punctuation">,</span> <span class="token string">"mxp"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//bat文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"504b0304140006000800"</span><span class="token punctuation">,</span> <span class="token string">"docx"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//docx文件</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"d0cf11e0a1b11ae10000"</span><span class="token punctuation">,</span> <span class="token string">"wps"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//WPS文字wps、表格et、演示dps都是一样的</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"6431303a637265617465"</span><span class="token punctuation">,</span> <span class="token string">"torrent"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"494d4b48010100000200"</span><span class="token punctuation">,</span> <span class="token string">"264"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    
    
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"6D6F6F76"</span><span class="token punctuation">,</span> <span class="token string">"mov"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Quicktime (mov)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"FF575043"</span><span class="token punctuation">,</span> <span class="token string">"wpd"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//WordPerfect (wpd)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"CFAD12FEC5FD746F"</span><span class="token punctuation">,</span> <span class="token string">"dbx"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Outlook Express (dbx)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"2142444E"</span><span class="token punctuation">,</span> <span class="token string">"pst"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Outlook (pst)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"AC9EBD8F"</span><span class="token punctuation">,</span> <span class="token string">"qdf"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Quicken (qdf)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"E3828596"</span><span class="token punctuation">,</span> <span class="token string">"pwl"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Windows Password (pwl)</span>
        FILE_TYPE_MAP<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"2E7261FD"</span><span class="token punctuation">,</span> <span class="token string">"ram"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Real Audio (ram)</span>
    <span class="token punctuation">}</span>
    

    }

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193

    参考文档
    [1]: https://blog.csdn.net/weixin_42440768/article/details/88870077
    [2]: https://www.jianshu.com/p/782730f7f016

                                    </div>
                <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-e44c3c0e64.css" rel="stylesheet">
                    </div>
    
    展开全文
  • 然后把其中的16进制数据提取出来,上代码: #include "stdlib.h" #include "stdio.h" typedef enum state //状态机实现 { IGNORE, WAITCR, WAITLF, READY, READ_L, READ_H }STATE; int AToI(unsigned...

    wireshark抓到的包可以导出:file->export->file

    在packet format下可以选择导出的格式,但如果需要的数据是多个包的组合那就麻烦了,因为导出的数据无论如何都会加上链路层、IP层和传输层的头信息,手动删除基本可能。

    比如,我捕获了很多RTP包,但我只想取出RTP的payload来分析数据是否正确,我可以这样做:


    首先导出packet byte格式的数据,我把该数据保存在RAW.dat中,数据的格式是这样的(一个wireshark中的包):



    然后把其中的16进制数据提取出来,上代码:

    #include "stdlib.h"
    #include "stdio.h"
    
    
    typedef enum state //状态机实现
    {
    	IGNORE,
    	WAITCR,
    	WAITLF,
    	READY,
    	READ_L,
    	READ_H
    }STATE;
    
    int AToI(unsigned char *pData)
    {
    	unsigned char tmp[2];
    	int ret;
    	tmp[0] = *pData;
    	tmp[1] = *(pData+1);
    	for (int i=0; i<2; i++)
    	{
    		if (tmp[i] <= 0x39 && tmp[i] >= 0x30)
    		{
    			tmp[i] &= 0x0f;
    		}
    		else if(tmp[i] <= 0x66 && tmp[i] >= 0x61)
    		{
    			tmp[i] = 9 + tmp[i]&0x0f;
    		}
    		else
    		{
    			printf("Err\n");
    			return -1;
    		}
    	}
    
    	ret = tmp[0]*16 + tmp[1];
    	return ret;
    }
    
    int main()
    {
    	FILE *FI, *FO;
    	
    	FI = fopen("RAW.dat", "rb");
    	FO = fopen("RTP.dat", "wb");
    	
    	STATE stat=IGNORE;
    	unsigned char tmp;
    	int hex;
    	unsigned char ch[2] = {0};
    	int count = 0, line = 0;
    	int blankCount = 0;
    	bool bFalse = false;
    	unsigned long PacketCount = 0;
    
    	while(!feof(FI) && !bFalse)
    	{
    		tmp = fgetc(FI);
    
    		switch(stat)
    		{
    		case IGNORE:
    			if (tmp == 0x20)
    			{
    				stat = READY;
    			}
    			break;
    		case WAITCR:
    			if (tmp == 0x0d)
    			{
    				stat = WAITLF;
    			}
    			break;
    		case WAITLF:
    			if (tmp == 0x0a)
    			{
    				stat = IGNORE;
    			}
    			break;
    		case READY:
    			if(tmp != 0x20)
    			{
    				ch[0] = tmp;
    				stat = READ_L;
    				blankCount = 0;
    			}
    			else
    			{
    				if (++blankCount >= 2)
    				{
    					PacketCount++;
    					blankCount = 0;
    					count = 0;
    					stat = WAITCR;
    				}
    			}
    			break;
    		case READ_L:
    			ch[1] = tmp;
    			stat = READ_H;
    			break;
    		case READ_H:
    			hex = AToI(ch);
    			if (hex < 0)
    			{
    				bFalse = true;
    				break;
    			}
    			fputc(hex, FO);
    			if (++count == 16)
    			{
    				count = 0;
    				line++;
    				stat = WAITCR;
    			}
    			else
    			{
    				stat = READY;
    			}
    			break;
    		}
    	}
    
    	fclose(FI);
    	fclose(FO);
    
    	return 0;
    }


    因为我抓取的是RTP数据,因此我又写了个小工具,从上面提取的裸数据中在一起提取出RTP数据:

    #include "stdlib.h"
    #include "stdio.h"
    
    #include <assert.h>
    
    int main()
    {
    	FILE *FI, *FO;
    
    	FI = fopen("raw.dat", "rb");
    	FO = fopen("rtp.dat", "wb");
    	if (!FI || !FO)
    	{
    		return -1;
    	}
    
    	int ret=0;
    	unsigned long ToTalLen=0, PacketLen = 0;
    	unsigned long count = 0;
    	unsigned char *pBuf = new unsigned char[10 * 1024 *1024];
    	unsigned char *pPos = pBuf;
    	int paddingLen = 0;
    	bool bHasPadding = false;
    
    	do
    	{
    		ret = fread(pPos, 1, 1024*1024, FI);
    		ToTalLen += ret;
    		pPos += ret;
    	}while(ret > 0);
    	pPos = pBuf;
    
    	do 
    	{	
    		while(ToTalLen > 0)
    		{
    			if(*pPos != 0x50 || *(pPos+1)!= 0xe5)
    			{
    				printf("Has decode %d\n", count);
    				break;
    			}
    			PacketLen = (*(pPos+38)<<8) + *(pPos+39);
    			PacketLen -= (8 + 12);
    			if (PacketLen > 1460)
    			{
    				break;
    			}
    
    			pPos += (14 + 20 + 8 + 12);
    
    			if (PacketLen != fwrite(pPos, 1, PacketLen, FO))
    			{
    				break;
    			}
    			count++;
    			pPos += PacketLen;
    			//如果RTP的payload是4, 那么以太网的包长度肯定为4 + 12 + 8 + 20 + 14 == 58 小于 60
    			//因此会有2个字节是需要丢弃的
    			if (PacketLen == 4)
    			{
    				pPos += 2;
    			}
    		}
    	} while(0);
    	
    	delete []pBuf;
    	fclose(FI);
    	fclose(FO);
    	return 0;
    }

    其他的传输层数据可以类似地提取,不用去掉RTP头长度(12)。


    展开全文
  • XnViewMP图片浏览器

    2021-11-10 18:11:54
    软件支持100多种图片格式,还具有浏览器、幻灯片、屏幕捕捉、缩略图制作、批处理转换、十六进制浏览、拖放、通讯录、扫描输入等功能。这款软件可以快速打开,完全可以替代系统的照片查看器使用,支持多种图片浏览...
  • 批量图片中找出相同的图片

    千次阅读 2019-12-04 16:49:44
    一波图片大概在50万张上下,无法通过人手来检查这些图片是否有存在复制粘贴,鱼目混珠的情况。 2.实现方法(20191203) 利用图片自带的exif属性判断 利用文件唯一的md5文件指纹判断 在图片中抽取若干像素,通过rgb来...
  • PHP 62进制转换函数_running8的博客-CSDN博客_php 62进制PHP 62进制转换函数_running8的博客-CSDN博客_php 62进制running8CSDN认证博客专家CSDN认证企业博客授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的...
  • } // ERROR 不符合动脉瘤的表现为 十进制小数0.625转换成十六进制小数是() 设3阶方阵A有特征值2,且已知|A|=5,则A的伴随矩阵A必有特征值. 讲授法的基本方式包括( ) 下列有关现金流量及现金流量图的表述,正确的...
  • 1.表单上传最传统的图片上传方式是form表单上传,使用form表单的input[type=”file”]控件,打开系统的文件选择对话框,从而达到选择文件并上传的目的。web上传图片的几种方法form表单上传表单上传需要注意以下几点...
  • Springboot上传图片到nginx

    千次阅读 2020-01-04 20:25:02
    springbot上传图片到本地和springmvc的类似,此处不再做介绍。可以参考:https://blog.csdn.net/duan196_118/article/details/103836831 本次介绍上传图片到nginx服务器。 1.编写连接Linux的配置文件,linux....
  • 使用Image2Lcd提取图片数据 ILI9320 TFT 显示图片
  • # 图片批量水印工具### 功能介绍- 1、批量给网站详细大图、缩略图添加文字或图片水印;- 2、文字水印相关设置,包括水印文字位置(九个位置可以选择)、字体颜色、字体、字号;- 3、图片水印相关设置,包括图片水印...
  • 简介Python有许多可视化工具,本文只介绍Matplotlib库。Matplotlib是一种2D的绘图库,可支持硬拷贝和跨...它不仅支持各种操作系统上许多不同的GUI后端,而且还能将图片导出为各种常见的矢量和光栅图:PDF、SVG、JP...
  • 大厂MongoDB面试题集锦

    2021-07-26 00:03:26
    MongoDB中的Map/Reduce主要是用来对数据进行批量处理和聚合操作。 Map和Reduce。Map函数调用emit(key,value)遍历集合中所有的记录,将key与value传给Reduce函数进行处理。 Map函数和Reduce函数是使用Javascript编写...
  • : 逢十六进一,十六进制的表示数字: 01234567ABCDEF 计算机容量的单位表示 1位 也就是一个二进制数(0 或 1)= 1bit 比特大小 8 bit 比特 = 1byte = 1字节 1024bytes = 1kbytes =1KB 1024个字符,小文档 ,...
  • 支持十六进制查看,JPEG无损旋转,可以调整亮度、对比度及去红眼等。启动软件后,会自动在鼠标右键菜单中添加图片预览功能,完全可以取代ACDSEE看图软件。图片打开速度快且不占用系统资源,可以自定更换皮肤。
  • As you can see, this is data never meant to be processed directly by humans, at least 为了说明这一点,让我们在十六进制编辑器中打开LDF文件,然后查看其中的内容。 如您所见,这是至少永远不会被人类直接...
  • Bugku-杂项部分题目WP

    千次阅读 2020-10-11 12:50:01
    图片放进010发现有一串二进制ASCII码获得一个关键词,但不知道是什么东西 然后通过搜索FFC2来修改JPEG图片的高度,把00改为01 这里猜出应该是一个7z压缩包文件头,应该被出题人改了文件头 7z的文件头是377...
  • 批量下载对路网图片并生成html的实现方法对路使用ajax实现异步加载内容,在它的js代码中找到了相关代码type : 'POST',url : '/index.php/request/new_data2/' + times + '/'+locinfo[domn][0],dataType : 'json',返回...
  • %x 十六进制整数 %e 指数 (基底写为e) %E 指数 (基底写为E) %f 浮点数 %F 浮点数,与上相同 %g 指数(e)或浮点数 (根据显示长度) %G 指数(E)或浮点数 (根据显示长度) %% 字符"%" ...
  • OpenGL入门学习[十六]

    2013-04-28 19:35:36
    Windows系统中,可以使用wglUseFontBitmaps函数来批量的产生显示字符用的显示列表。函数有四个参数: 第一个参数是HDC,学过Windows GDI的朋友应该会熟悉这个。如果没有学过,那也没关系,只要知道调用...
  • 可用于批量获取有地理信息的图片 可以得到经纬度的信息 代码: import glob import os from PIL import Image from PIL.ExifTags import TAGS def exif(img): exifData = {} try: i = Image.open(img) # 读取...
  • } }复制代码 2,MD5: 与guid 一样会输出32 字符十六进制数,区别是guid是随机产生的,md5需要根据输入的数据生成。 例子: $str = "Hello"; echo md5($str); ?>复制代码 输出结果: 8b1a9953c4611296a827abf8c...
  • 最开始是看了一个b站视频,他采用了python加vba实现了将一个图片转化在excel表格当中。https://www.bilibili.com/video/av55033139?t=300 首先是python代码 这里有个相对陌生的模块pIL(Python Imaging Library)...
  • 十六进制软件打开其中一个后 拉到最底部可以发现其中包含图片和音频,如下图: ![图片说明](https://img-ask.csdn.net/upload/201704/07/1491572017_798934.png) 观察多个zpk文件发现 1、每个zpk最多有5个文件...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 2,878
精华内容 1,151
关键字:

十六进制批量转图片