简单且快速完成-
- Function Encrypt(ByVal text As String, _
- ByVal mask As String) _
- As String
- Dim i As Long, _
- j As Long
-
- Dim textBytes() As Byte, _
- maskBytes() As Byte
-
- Dim lbMask As Long, _
- ubMask As Long
-
- Dim xorCode As Integer
- textBytes = text
- maskBytes = mask
-
- lbMask = LBound(maskBytes)
- ubMask = UBound(maskBytes)
-
- j = LBound(maskBytes)
-
- For i = LBound(textBytes) To UBound(textBytes) Step 2
- xorCode = textBytes(i) Xor maskBytes(j)
- '' modify this to suit
- If 32 34 Then textBytes(i) = xorCode
- j = j + 2: If ubMask < j Then j = lbMask
- Next i
-
- Encrypt = textBytes
- End Function
在VB的即时窗口中测试-
?encrypt(" http://www . the swamp . org "," 123456")
YFGD://EDC。BYW@CT[A.\FR
?加密(" YFGD://EDC。BYW@CT[A.\FR "," 123456 ")
http://www . the swamp . org |