gpt4 book ai didi

asp-classic - 带有 Base64 类型十六进制的经典 ASP

转载 作者:行者123 更新时间:2023-12-03 16:47:14 25 4
gpt4 key购买 nike

此代码使用 sha256 加密

7353cf97ed9471d8b1ca180b6277f855f27214668d40d3b0134b8c91c8bb51a8
我用 Base64 编码时的结果 NzM1M2NmOTdlZDk0NzFkOGIxY2ExODBiNjI3N2Y4NTVmMjcyMTQ2NjhkNDBkM2IwMTM0YjhjOTFjOGJiNTFhOA==但我想得到这样的结果。
c1PPl+2UcdixyhgLYnf4VfJyFGaNQNOwE0uMkci7Uag=
https://emn178.github.io/online-tools/base64_encode.html
我可以在此在线转换器站点上获得此结果。 (您必须选择 十六进制 输入类型)
我使用的 base64 代码:
Function Base64Encode(sText)
Dim oXML, oNode
Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.nodeTypedValue = Stream_StringToBinary(sText)
Base64Encode = oNode.text
Set oNode = Nothing
Set oXML = Nothing
End Function
Function Base64Decode(ByVal vCode)
Dim oXML, oNode
Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.text = vCode
Base64Decode = Stream_BinaryToString(oNode.nodeTypedValue)
Set oNode = Nothing
Set oXML = Nothing
End Function
Private Function Stream_StringToBinary(Text)
Const adTypeText = 2
Const adTypeBinary = 1
Dim BinaryStream 'As New Stream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeText
BinaryStream.CharSet = "us-ascii"
BinaryStream.Open
BinaryStream.WriteText Text
BinaryStream.Position = 0
BinaryStream.Type = adTypeBinary
BinaryStream.Position = 0
Stream_StringToBinary = BinaryStream.Read
Set BinaryStream = Nothing
End Function
Private Function Stream_BinaryToString(Binary)
Const adTypeText = 2
Const adTypeBinary = 1
Dim BinaryStream 'As New Stream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeBinary
BinaryStream.Open
BinaryStream.Write Binary
BinaryStream.Position = 0
BinaryStream.Type = adTypeText
BinaryStream.CharSet = "us-ascii"
Stream_BinaryToString = BinaryStream.ReadText
Set BinaryStream = Nothing
End Function
我怎么能用经典的asp

最佳答案

您必须先解码十六进制字符串。
得到相应的原始值后,可以将其转换为 Base64 字符串。

Function HexStringToBytes(hexString)
With CreateObject("MSXML2.DOMDocument")
.LoadXml "<node/>"
With .DocumentElement
.DataType = "bin.hex"
.Text = hexString
HexStringToBytes = .NodeTypedValue
End With
End With
End Function

Function BytesToBase64String(bytes)
With CreateObject("MSXML2.DOMDocument")
.LoadXml "<node/>"
With .DocumentElement
.DataType = "bin.base64"
.NodeTypedValue = bytes
BytesToBase64String = Replace(.Text, vbLf, "")
End With
End With
End Function

Function HexStringToBase64String(hexString)
Dim bytes, base64string

bytes = HexStringToBytes(hexString)
base64string = BytesToBase64String(bytes)

HexStringToBase64String = base64string
End Function

hexStr = "7353cf97ed9471d8b1ca180b6277f855f27214668d40d3b0134b8c91c8bb51a8"

base64str = HexStringToBase64String(hexStr)

'Response.Write(base64str) 'prints c1PPl+2UcdixyhgLYnf4VfJyFGaNQNOwE0uMkci7Uag=

关于asp-classic - 带有 Base64 类型十六进制的经典 ASP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65150128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com