|
用vb实现DES加解密算法(二)--加密(1)
'sCode 待加密字串 'sKey 密钥字串(前8位有效) Public Sub DES_Encode(ByRef sCode() As Byte, ByVal sKey As String, ByRef bReturn() As Byte) Attribute DES_Encode.VB_Description = "加密 sCode:明文16进制串 sKey:密钥文本,前8位有效 bReturn:密文16进制串" Dim tempKey() As Byte '存放密钥 Dim BinKey(63) As Byte '64位二进制原始密钥 Dim KeyPC_1(55) As Byte '存放56位密钥 Dim tempCode(7) As Byte '存放8位原始明文 Dim tempReturn(7) As Byte '存放8位密文 Dim BinCode(63) As Byte '存放64位明文 Dim CodeIP(63) As Byte '存放IP置换结果 Dim CodeE(47) As Byte 'E膨胀结果 Dim CodeP(31) As Byte 'P变换结果 Dim RetS(47) As Byte 'S盒运算32位结果 Dim S(7) As Byte 'S盒运算8个结果 Dim CodeS1(5) As Byte: Dim CodeS2(5) As Byte: Dim CodeS3(5) As Byte: Dim CodeS4(5) As Byte Dim CodeS5(5) As Byte: Dim CodeS6(5) As Byte: Dim CodeS7(5) As Byte: Dim CodeS8(5) As Byte Dim L0(31) As Byte: Dim R0(31) As Byte Dim L1(31) As Byte: Dim R1(31) As Byte Dim L2(31) As Byte: Dim R2(31) As Byte Dim L3(31) As Byte: Dim R3(31) As Byte Dim L4(31) As Byte: Dim R4(31) As Byte Dim L5(31) As Byte: Dim R5(31) As Byte
|