BASE64编码转换成二进制

时间:2022-11-12 20:35:41
通过xmlhttp得到一个xml文件,里面一个节点是二进制转化的BASE编码字符。
我要转化成二进制,才能生成图片!

能adodb.stream把BASE64编码转成二进制吗?
谢谢大家帮忙!

7 个解决方案

#1


1、test.xml

<?xml version="1.0"?>
<data>
<![CDATA[
R0lGODlhIwAqAOYAAOfq9ImGtLd0iaaix8bE2gCL2v/3AO+WDe6amWpjmQWR2rq30gCb5ud7eZVO
b//oANjSDOInMv/7++qGgxQpi8kzQ/KlC/fDB5ycwlhHTv3m5ZWUvNx0dltYmFdJmkg2Vy4ZaxcN
blRuo6CMKsG+1zl6tdHS43tZgdjO3VxIjbk7UPT0+K5BWmxro/GNiPmcleyioZyV0+dzb5N7MRKM
0gCh7H53q+eBfmRPkVponQV3yP7aAeHdBfCpqAlqundoOdnY5yqFyElEi/a7udvb6bKxzvnJx083
ghsfeaNGYe7u9eHe6uXl783M4DsnXPS2CAtDmg06neniBbmmv+Ftbf3z8/Skn7WrywWDzwxTpxuJ
zqOYvvva2el1EdCquNPb7pWAqNzk8To4gzUwd5ejzI+Lt09MkI+WwXl/tGZwrHhso2pXlrG62OrE
yMCyHaury/XNB4OCsqicwd6do/P//+98ds+Bi1JRlNzDzM3W6bvF4eStsv6zrACV4ACT3f///yH5
BAAAAAAALAAAAAAjACoAAAf/gFQIg4SFhoeIhjIyf42Oj5CRkpA3MhKOJAMDMZydnp+emiSPE5aO
OCEhHxmsrayrH7GyTiCpKaSmjSkhIxBSv1I8wsMQPBDHyD8hHo+Vl40eGQbTD9XU19PZ01JOt47O
jh4/OxZPBxboFxYH6uzrT+gWOxnM37l/4gdd++vlBwfmzv1b9w8OvWd/wEH7cUEguicNLcA5p85C
xQNwPtRrpBDfj2w7Qj4wsGNkSQPWHuyAI0Ujwo7iDEAYMaOmzZszRujsNc3Jxj+lEIpz4yQEhaNI
kyodMwMCiBRMTJgA0kAGgSIEmHj44CSKjgJgw4od6yPKBxBCNthIEIeDjAEt/zoE2BWF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XCDg7hZ5fGFDC3FQgg2E
kIMvsGEKMLjBEKpwP0hUwQhWmEAP2jCFNwALAzYAgxdcxwf7NdCBGjBCDxDRAyNoACGSCAQAOw==
]]>
</data>

#2


2、test.asp

<%
Dim xml : Set xml=Server.CreateObject("MSXML2.DOMDocument")
Dim stm : Set stm=Server.CreateObject("ADODB.Stream")
xml.resolveExternals=False
xml.load Server.MapPath("test.xml")
xml.documentElement.setAttribute "xmlns:dt","urn:schemas-microsoft-com:datatypes"
xml.documentElement.dataType = "bin.base64"
stm.Type=1 'adTypeBinary
stm.Open
stm.Write xml.documentElement.nodeTypedValue
stm.SaveToFile Server.MapPath("1.gif")
stm.Close
Set xml=Nothing
Set stm=Nothing
%>

#3


3、原图片是:
http://mat1.qq.com/www/images/ind35.gif

4、将两个文件放在Web服务器的同一个目录下,用浏览器打开test.asp
 将生成一个文件1.gif,这个就是解码后的二进制文件
 比较一下,和原图是否一样?

#4


test.asp内容:
================================
<%
Dim xml : Set xml=Server.CreateObject("MSXML2.DOMDocument")
Dim stm : Set stm=Server.CreateObject("ADODB.Stream")
xml.resolveExternals=False
xml.load Server.MapPath("test.xml")
xml.documentElement.setAttribute "xmlns:dt","urn:schemas-microsoft-com:datatypes"
xml.documentElement.dataType = "bin.base64"
stm.Type=1 'adTypeBinary
stm.Open
stm.Write xml.documentElement.nodeTypedValue
'stm.SaveToFile Server.MapPath("1.gif")
Response.ContentType="images/gif"
stm.Position=0
Response.BinaryWrite stm.Read()
stm.Close
Set xml=Nothing
Set stm=Nothing
%>

======================
再其他文件这么引用:
<img src="http://localhost/test.asp" />

#5


good,序列化

#6


可惜了 我只知道C++的将BASE64编码转化成二进制 不知道web上怎么实现〉。。。
惭愧了

#7


怎么没人结贴?

#1


1、test.xml

<?xml version="1.0"?>
<data>
<![CDATA[
R0lGODlhIwAqAOYAAOfq9ImGtLd0iaaix8bE2gCL2v/3AO+WDe6amWpjmQWR2rq30gCb5ud7eZVO
b//oANjSDOInMv/7++qGgxQpi8k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BCye4dgJ4+fWx3xEtiCFGHFUBMQAGTWhYwGV+sFZBCTTkEEQOJDq4
WRxCdFAGB1RsIOAGMtKogP8DCdhVAwM5JJEDjSYiscYKQDChRAMNNFFGGSassSGNjdmlRQmY2UXl
fgkQQYIJoDUAAAELLKEGEhw6pkUQQYSoYxCWdaeZDUbe0cIi0m3whg1I6MDYZbItGAGCFeTwKGY+
gDDAGwkIEUAddRCAxgYLkABCFo+mxkISJcQWRAkRnHApA1mAQAQTdE4xwQRthLEAASukUJdqNCTh
QIgs5DDiCcT1gRsQGLwBwB6D9AAAXEWUEcJifvShhQMsTJpcbCdcxoAOIWzBaQJkTDCEEROw0UEC
ZSxxBBSztgqicgzIx0AUR6zABAZnTCGDBhrUgQcGRRTBhBwh+FBDYzSUkFz/BB+KEGgNPoRwBa4A
0DGHCxJIgAAMAJAQBwYAoIJFDX2MqIIDOYiwYAkM1IBuAkCo9wYKDRjRiBENoBBHBy28YW8IOtRQ
QgIlKGBXxVJ3nAIAnLaQhgAkN2KyFfK20MQfKBwRQhYF1KC2kzUUAEUIRywBgGhngEEFF49wMYEX
bDSBHRFAJAACElD4oMPhPrwNghq40msCABzAEMkQDWigRxxlDPDHClekAEItqXyOwxUSENHCHXec
YUXXkfQwAXZlLEDEGyasQEIZNuS+RRMrEPHZBjkE4MANGkwiQQ8u4PFFGDZ0YMMSC7yxgBJNFAHE
AgmM0cLcdkxQ/CR/SDCEXgtDEEBGC7G3kHvPd8RBwB1poOHFCy98D34jXCDg7hZ5fGFDC3FQgg2E
kIMvsGEKMLjBEKpwP0hUwQhWmEAP2jCFNwALAzYAgxdcxwf7NdCBGjBCDxDRAyNoACGSCAQAOw==
]]>
</data>

#2


2、test.asp

<%
Dim xml : Set xml=Server.CreateObject("MSXML2.DOMDocument")
Dim stm : Set stm=Server.CreateObject("ADODB.Stream")
xml.resolveExternals=False
xml.load Server.MapPath("test.xml")
xml.documentElement.setAttribute "xmlns:dt","urn:schemas-microsoft-com:datatypes"
xml.documentElement.dataType = "bin.base64"
stm.Type=1 'adTypeBinary
stm.Open
stm.Write xml.documentElement.nodeTypedValue
stm.SaveToFile Server.MapPath("1.gif")
stm.Close
Set xml=Nothing
Set stm=Nothing
%>

#3


3、原图片是:
http://mat1.qq.com/www/images/ind35.gif

4、将两个文件放在Web服务器的同一个目录下,用浏览器打开test.asp
 将生成一个文件1.gif,这个就是解码后的二进制文件
 比较一下,和原图是否一样?

#4


test.asp内容:
================================
<%
Dim xml : Set xml=Server.CreateObject("MSXML2.DOMDocument")
Dim stm : Set stm=Server.CreateObject("ADODB.Stream")
xml.resolveExternals=False
xml.load Server.MapPath("test.xml")
xml.documentElement.setAttribute "xmlns:dt","urn:schemas-microsoft-com:datatypes"
xml.documentElement.dataType = "bin.base64"
stm.Type=1 'adTypeBinary
stm.Open
stm.Write xml.documentElement.nodeTypedValue
'stm.SaveToFile Server.MapPath("1.gif")
Response.ContentType="images/gif"
stm.Position=0
Response.BinaryWrite stm.Read()
stm.Close
Set xml=Nothing
Set stm=Nothing
%>

======================
再其他文件这么引用:
<img src="http://localhost/test.asp" />

#5


good,序列化

#6


可惜了 我只知道C++的将BASE64编码转化成二进制 不知道web上怎么实现〉。。。
惭愧了

#7


怎么没人结贴?