没有合适的资源?快使用搜索试试~ 我知道了~
用于Baidu上传图片OCR识别 百度规定先B64编码再URLEncode上传
资源推荐
资源详情
资源评论
Function Base64Encode(Str() As Byte) As String 'Base64 ±àÂë
On Error GoTo over 'ÅÅ´í
Dim buf() As Byte, Length As Long, mods As Long
Const B64_CHAR_DICT = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
mods = (UBound(Str) + 1) Mod 3 '³ýÒÔ3µÄÓàÊý
Length = UBound(Str) + 1 - mods
ReDim buf(Length / 3 * 4 + IIf(mods <> 0, 4, 0) - 1)
Dim i As Long
For i = 0 To Length - 1 Step 3
buf(i / 3 * 4) = (Str(i) And &HFC) / &H4
buf(i / 3 * 4 + 1) = (Str(i) And &H3) * &H10 + (Str(i + 1) And &HF0) / &H10
buf(i / 3 * 4 + 2) = (Str(i + 1) And &HF) * &H4 + (Str(i + 2) And &HC0) / &H40
buf(i / 3 * 4 + 3) = Str(i + 2) And &H3F
DoEvents
Next
If mods = 1 Then
buf(Length / 3 * 4) = (Str(Length) And &HFC) / &H4
buf(Length / 3 * 4 + 1) = (Str(Length) And &H3) * &H10
buf(Length / 3 * 4 + 2) = 64
buf(Length / 3 * 4 + 3) = 64
ElseIf mods = 2 Then
buf(Length / 3 * 4) = (Str(Length) And &HFC) / &H4
buf(Length / 3 * 4 + 1) = (Str(Length) And &H3) * &H10 + (Str(Length + 1) And &HF0) / &H10
buf(Length / 3 * 4 + 2) = (Str(Length + 1) And &HF) * &H4
buf(Length / 3 * 4 + 3) = 64
End If
For i = 0 To UBound(buf)
Base64Encode = Base64Encode + Mid(B64_CHAR_DICT, buf(i) + 1, 1)
DoEvents
Next
On Error GoTo over 'ÅÅ´í
Dim buf() As Byte, Length As Long, mods As Long
Const B64_CHAR_DICT = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
mods = (UBound(Str) + 1) Mod 3 '³ýÒÔ3µÄÓàÊý
Length = UBound(Str) + 1 - mods
ReDim buf(Length / 3 * 4 + IIf(mods <> 0, 4, 0) - 1)
Dim i As Long
For i = 0 To Length - 1 Step 3
buf(i / 3 * 4) = (Str(i) And &HFC) / &H4
buf(i / 3 * 4 + 1) = (Str(i) And &H3) * &H10 + (Str(i + 1) And &HF0) / &H10
buf(i / 3 * 4 + 2) = (Str(i + 1) And &HF) * &H4 + (Str(i + 2) And &HC0) / &H40
buf(i / 3 * 4 + 3) = Str(i + 2) And &H3F
DoEvents
Next
If mods = 1 Then
buf(Length / 3 * 4) = (Str(Length) And &HFC) / &H4
buf(Length / 3 * 4 + 1) = (Str(Length) And &H3) * &H10
buf(Length / 3 * 4 + 2) = 64
buf(Length / 3 * 4 + 3) = 64
ElseIf mods = 2 Then
buf(Length / 3 * 4) = (Str(Length) And &HFC) / &H4
buf(Length / 3 * 4 + 1) = (Str(Length) And &H3) * &H10 + (Str(Length + 1) And &HF0) / &H10
buf(Length / 3 * 4 + 2) = (Str(Length + 1) And &HF) * &H4
buf(Length / 3 * 4 + 3) = 64
End If
For i = 0 To UBound(buf)
Base64Encode = Base64Encode + Mid(B64_CHAR_DICT, buf(i) + 1, 1)
DoEvents
Next
资源评论
llzzllllz
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功