Option Strict Off
Option Explicit On
Option Compare Text
Imports Microsoft.VisualBasic.Compatibility
Namespace Blood.Com.ClassLib
Public Class Security
Private pbBase64Byt(63) As Byte
Private Const BASE64CHR As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
Private Const Q_CODE_HDR As String = "=?ISO-8859-1?Q?"
Private Const B_CODE_HDR As String = "=?ISO-8859-1?B?"
Private Const CODE_END As String = "?="
Public Sub New()
MyBase.New()
Dim intPtr As Integer
For intPtr = 0 To 63
pbBase64Byt(intPtr) = Asc(Mid(BASE64CHR, intPtr + 1, 1))
Next
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
'对字符串进行B或Q编码
Public Function EnText(ByRef sIn As String) As String
Dim iPtr As Short
Dim bNeedsEncoding As Boolean
Dim iMax As Short
Dim sChr As String
Dim sLine As String
Dim sQCode As String
Dim sBCode As String
Dim bytTmp() As Byte
bytTmp = System.Text.UnicodeEncoding.Default.GetBytes(sIn)
For iPtr = 0 To UBound(bytTmp)
If bytTmp(iPtr) > 126 Then
bNeedsEncoding = True
Exit For
End If
Next
EnText = sIn
'Q 编码
iMax = 54
&nbs