⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cod_differ.bas

📁 21加密算法,用vB语言编写实现,可了解各种加密算法的结构
💻 BAS
字号:
Attribute VB_Name = "Cod_Differ"


Option Explicit

'This coder calculates the difference between two codes
'if the first code = 20 and the second code = 15 then then difference
'between those two = -5
'because negative numbers can't be stored in a byte and the range
'can go from -128 to +127, the 0 is stored as 128 so the
'value -5 will become -5+128=123
'  0 = -128
'127 = -1
'128 = 0
'129 = 1
'255 = 127

Public Sub Difference_Coder(ByteArray() As Byte)
    Dim X As Long
    Dim LastCode As Integer
    Dim NewCode As Integer
    Dim OutStream() As Byte
    LastCode = ByteArray(0)
    For X = 1 To UBound(ByteArray)
        NewCode = LastCode - ByteArray(X)
        If NewCode < -128 Then NewCode = NewCode + 256
        If NewCode > 127 Then NewCode = NewCode - 256
        NewCode = 128 + NewCode
        LastCode = ByteArray(X)
        ByteArray(X) = NewCode
    Next
End Sub

Public Sub Difference_DeCoder(ByteArray() As Byte)
    Dim X As Long
    Dim LastCode As Integer
    Dim NewCode As Integer
    Dim OutStream() As Byte
    LastCode = ByteArray(0)
    For X = 1 To UBound(ByteArray)
        NewCode = ByteArray(X) - 128
        LastCode = LastCode - NewCode
        If LastCode < 0 Then LastCode = LastCode + 256
        If LastCode > 255 Then LastCode = LastCode - 256
        ByteArray(X) = LastCode
    Next
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -