不可识别文件到可识别文件的测试

说到把不可识别文件转换成可识别文件大家一定会想到B6编码。

我们最常用的就是email了。
比如说:信的内容是文本,附件的类型可能是图片,视频,音频文件等等。在发送email的时候首先把这些文件分别编码,用内容类型分割符号分割开来。然后做为一个整体发送出去。
接收email的程序在对于每一断内容进行解码。解码的过程是最复杂的,因为email可以作为附件发送,而email的email也可以看做一个附件。。

一般一个简单的email正文件格式如下:

Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: base64
Message-Id: 
 
xxxx----
 
Content-Type: image/gif
Content-Transfer-Encoding: base64
Message-Id:
 
xxx----

这封信就是一个文本内容加上一个简单的图片附件格式发送的。

这个是在email中的应用,我就不多说了。

我说一下在mht文件中的应用。
如果不了解mht文件请到google中搜索一下相关文章。

首先,我们做一个简单的测试。把现面这个图片做一个b6编码。

B6编码如下:

R0lGODlheAB4APf/AAAtnf/39Ao7pKO64hFLrf8TCv+hjZy24Nnj9AAlmiNatAo1of8jCgA1ocHR
7Pb4/v/49hxVsf8yEWuRzv8JAP9FIszZ8FyGyf/8+5mz3//6+AAclObs+fH1/P+smvn6/v9KJfv8
/3KX0f9ZOf8KCqrA5LzN6o6q2fT3/f/d1bHF5v/28/99Yvz9/0Jyv/8aCv85FP/WzP+yon2e1HeZ
0cXV7v/08Heb0vr7/pSu3AoblGGIyd3m9v/w7P8eCujt+QA5o/9kSTVpvAAWkuzx+ithtgAhl/88
GP+Wf//BtP8OCv/9/K7D5QxGqSpftoKh1v8EAIin2P/FuP/i2v9OK6/F5k16xP+wnP/Z0FN/xf+b
iIuq25aw3ai94+Hp9/+JcP8qCP9UM/L2/P/y7v+mlP9iQurw+v/s5tfh9Aoomv+PeWuOzP9dPdvl
9f/a0Qosnv96XP/SyP8OAER0wAArnP9pTEh2wbnK6e7y+//q5ApAp/8vD//k3Qown2eNzdDc8QAo
m/8zC/9AHP9uUP+AZzttvf+dhkx4w+Ts+AoflmSKyv+ahi9kuP9zVv+9rz1wvv+qmUl5wv+Gbf+E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9TCUTDnFVHul+BcYOr2d0iupA/rsDwKbChvg//x6mls2l/fIYgYmIQKRjejZrP2jTngC+p
/jGIzSAaBHAAAcvnE/QljGhKFGBA21AjBwYFYhRlQIWOpBNt0xBjs3LgjwbwQwESVbYAbpDySgxy
lsoG4SBl8IeYK7sHPsTa43CRwWbZNBBpDAK6OvLBIhJjgBfYpcc+OMIRfLCp20HCB+4twBdkwwtd
6CLPl5EPKyRdkFfYoAfSCPJEpNEDGxA3O9qg1OVZWxBbhJczz+B9QW7x+0TLnrEYoAuGBGFb4f9D
HFVJr/MNMgXUT//6jA0IADs=

注意标准的b6编码应该是矩形的。

如果你把这个文件解码的时候,必须读一行解一行。还可以把这些字符用b6反编码会原来的图片。

下面我们建立一个mht文件,内容如下:

gif.mht

-----------------------------------------------
Content-Type: image/gif;
Content-Transfer-Encoding: base64
Message-Id:
 
R0lGODlheAB4APf/AAAtnf/39Ao7pKO64hFLrf8TCv+hjZy24Nnj9AAlmiNatAo1of8jCgA1ocHR
7Pb4/v/49hxVsf8yEWuRzv8JAP9FIszZ8FyGyf/8+5mz3//6+AAclObs+fH1/P+smvn6/v9KJfv8
/3KX0f9ZOf8KCqrA5LzN6o6q2fT3/f/d1bHF5v/28/99Yvz9/0Jyv/8aCv85FP/WzP+yon2e1HeZ
0cXV7v/08Heb0vr7/pSu3AoblGGIyd3m9v/w7P8eCujt+QA5o/9kSTVpvAAWkuzx+ithtgAhl/88
GP+Wf//BtP8OCv/9/K7D5QxGqSpftoKh1v8EAIin2P/FuP/i2v9OK6/F5k16xP+wnP/Z0FN/xf+b
iIuq25aw3ai94+Hp9/+JcP8qCP9UM/L2/P/y7v+mlP9iQurw+v/s5tfh9Aoomv+PeWuOzP9dPdvl
9f/a0Qosnv96XP/SyP8OAER0wAArnP9pTEh2wbnK6e7y+//q5ApAp/8vD//k3Qown2eNzdDc8QAo
m/8zC/9AHP9uUP+AZzttvf+dhkx4w+Ts+AoflmSKyv+ahi9kuP9zVv+9rz1wvv+qmU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sg
QD5Y4Y9TCUTDnFVHul+BcYOr2d0iupA/rsDwKbChvg//x6mls2l/fIYgYmIQKRjejZrP2jTngC+p
/jGIzSAaBHAAAcvnE/QljGhKFGBA21AjBwYFYhRlQIWOpBNt0xBjs3LgjwbwQwESVbYAbpDySgxy
lsoG4SBl8IeYK7sHPsTa43CRwWbZNBBpDAK6OvLBIhJjgBfYpcc+OMIRfLCp20HCB+4twBdkwwtd
6CLPl5EPKyRdkFfYoAfSCPJEpNEDGxA3O9qg1OVZWxBbhJczz+B9QW7x+0TLnrEYoAuGBGFb4f9D
HFVJr/MNMgXUT//6jA0IADs=

然后用MS.IE打开看看,看到了什么,是不是那张图片。

然后你在用浏览器的查看源文件,看到的信息如下:

<center><img src="CID:{CC62AC91-89CF-432A-8673-4A9379C85E62}/ATT00001.gif" alt="" /></center>

象Mozilla Firefox 等浏览器还是不支持的.

分享到: 更多