• vb 加密算法
• vb 加密代码 VB加密算法DES程序源代码收藏
• 21种VB加密/解密算法源代码，另外还有50多种种压缩/解压算法源码，相信够你用了，觉得还不错吧，推荐给大家。
• 一共6层加密 1。字符----》ASCII ...由于本人是菜鸟，所以这个加密算法可能很烂，请见谅！ 有一部分文字和字符转化后可能无法复原，如果能解决请联系我，谢谢！ 邮箱：834449164@qq.com QQ:834449164
• Public Function Encode(ByVal s As String) As String '加密  On Error GoTo err  If Len(s) = 0 Then Exit Function  Dim Buff() As Byte  Buff = StrConv(s, vbFromUnicode)  Dim i As Long
Public Function Encode(ByVal s As String) As String '加密
On Error GoTo err
If Len(s) = 0 Then Exit Function
Dim Buff() As Byte
Buff = StrConv(s, vbFromUnicode)
Dim i As Long
Dim j As Byte
Dim k As Byte, m As Byte
Dim mstr As String
mstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
Dim outs As String
i = UBound(Buff) + 1
outs = Space(2 * i)
Dim Temps As String
For i = 0 To UBound(Buff)
Randomize Time
j = CByte(5 * (Math.Rnd()) + 0) '
Buff(i) = Buff(i) Xor j
k = Buff(i) Mod Len(mstr)
m = Buff(i) \ Len(mstr)
m = m * 2 ^ 3 + j
Temps = Mid(mstr, k + 1, 1) + Mid(mstr, m + 1, 1)
Mid(outs, 2 * i + 1, 2) = Temps
Next
Encode = outs
Exit Function
err:
End Function
Public Function Decode(ByVal s As String) As String '解密
On Error GoTo err
Dim i As Long
Dim j As Byte
Dim k As Byte
Dim m As Byte
Dim mstr As String
mstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
Dim T1 As String, T2 As String
Dim Buff() As Byte
Dim n As Long
n = 0
For i = 1 To Len(s) Step 2
T1 = Mid(s, i, 1)
T2 = Mid(s, i + 1, 1)
k = InStr(1, mstr, T1) - 1
m = InStr(1, mstr, T2) - 1
j = m \ 2 ^ 3
m = m - j * 2 ^ 3
ReDim Preserve Buff(n)
Buff(n) = j * Len(mstr) + k
Buff(n) = Buff(n) Xor m
n = n + 1
Next
Decode = StrConv(Buff, vbUnicode)
Exit Function
err:
Decode = ""End Function

>>java转换

public class EDcode {public static void main(String[] s) throws Exception{   String ss=StringEncode("123456锦是方法");   String ds= StringDecode(ss);   System.out.println(ds);  }static String  StringEncode(String s) throws Exception{   byte j;   byte k;   byte m;   String mstr="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";   byte[] Buff=s.getBytes("GBK");   char[] outs=new char[s.getBytes("GBK").length*2];   for(int i=0;i<Buff.length;i++){     j=(byte) (Math.random()*5+0.5);       //Buff[i] =(byte) ((Buff[i]&0xFF) ^ j);    k = (byte)(((Buff[i]&0xFF) ^ j) %mstr.length());   m = (byte)(((Buff[i]&0xFF) / mstr.length())* 8 + j);
outs[2 * i + 0]= mstr.charAt(k);
outs[2 * i + 1]= mstr.charAt(m);   }   return String.valueOf(outs);}static String  StringDecode(String s) throws Exception{   byte j;   byte k;   byte m;   String mstr="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";     char t1,t2;   int n=0;   byte[] Buff = new byte[s.length()/2];   for(int i=0;i<s.length();i+=2){    t1 = s.charAt(i);//Mid(s, i, 1)        t2 =  s.charAt(i+1);       k = (byte)mstr.indexOf(t1);       m = (byte)mstr.indexOf(t2);              j = (byte)(m/8);              m = (byte)(m - j * 8);          //  Buff[n]= (char)(j *mstr.length() + k);       Buff[n] = (byte)((j *mstr.length() + k)^ m);       n ++;   }   return new String(Buff);}
}

展开全文
• ## VB加密算法DES程序源代码

千次阅读 热门讨论 2005-10-04 10:58:00
' bFlag As Byte 可选输入,为2则解密,其它或为缺省时为加密   '==========================================================================================   Sub Encrypt3Des_ArrToArr(m_bit() As Byte...
'************************************************************************     '*     '*     '* DES/3DES 加解密类模块 V1.0     '*     '* 开发:张新扬     '* 2005.08.24     '*     '*     '************************************************************************                    '     '======= 私有变量 =======          Private ip(63) As Byte, ip_1(63) As Byte, e(47) As Byte '数据变换     Private pc_1(55) As Integer, pc_2(47) As Integer, ccmovebit(15) As Integer '密钥生成     Private p(31) As Byte, ss(7, 3, 15) As Byte 'S变换     Private key_n1(15, 7) As Byte '密钥1     Private key_n2(15, 7) As Byte '密钥2          '     '======= API =========     Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)               '     '***************************************************************     '     '==================== 下面是类的函数及方法 ===================     '     '***************************************************************                                   '==========================================================================================     ' SetKey 函数说明：     ' 设置3DES加/解密的密钥     ' 返回：     ' 无     ' 参数：     ' K_Bit() AS Byte 密钥,不少于16个元素     '==========================================================================================     Sub SetKey(K_Bit() As Byte)      Dim Key() As Byte      Dim K_Bit1(7) As Byte      Dim K_Bit2(7) As Byte           Key = K_Bit      ReDim Preserve Key(15) As Byte                CopyMemory K_Bit1(0), Key(0), 8      CopyMemory K_Bit2(0), Key(8), 8           '//根据密钥生成16个子密钥      GenSubKey K_Bit1(), key_n1()      GenSubKey K_Bit2(), key_n2()     End Sub               '==========================================================================================     ' SetKey1 函数说明：     ' 设置3DES加/解密的的第一个密钥     ' 返回：     ' 无     ' 参数：     ' K_Bit() AS Byte 密钥,不少于8个元素     '==========================================================================================     Sub SetKey1(K_Bit() As Byte)      '//根据密钥生成16个子密钥      Dim Key() As Byte      ReDim Preserve Key(7) As Byte      GenSubKey Key(), key_n1()     End Sub                    '=========================================================================================     ' SetKey2 函数说明：     ' 设置3DES加/解密的的第二个密钥     ' 返回：     ' 无     ' 参数：     ' K_Bit() AS Byte 密钥,不少于8个元素     '==========================================================================================     Sub SetKey2(K_Bit() As Byte)      '//根据密钥生成16个子密钥      Dim Key() As Byte      ReDim Preserve Key(7) As Byte      GenSubKey Key(), key_n2()     End Sub                    '==========================================================================================     ' Encrypt3Des_ArrToArr 函数说明：     ' 3DES加/解密     ' 返回：     ' 无     ' 参数：     ' m_bit() As Byte 输入     ' e_bit() As Byte 输出 ,元素个数为8的倍数     ' bFlag As Byte 可选输入,为2则解密,其它或为缺省时为加密     '==========================================================================================     Sub Encrypt3Des_ArrToArr(m_bit() As Byte, e_bit() As Byte, Optional bFlag As Byte = 1)      Dim i As Integer      Dim ina() As Byte, outa() As Byte           ina = m_bit      EncryptDes_ArrToArr ina(), outa(), 1, bFlag      ina = outa      EncryptDes_ArrToArr ina(), outa(), 2, 3 - bFlag      ina = outa      EncryptDes_ArrToArr ina(), outa(), 1, bFlag      ReDim e_bit(UBound(outa)) As Byte      'For i = 0 To UBound(outa)      ' e_bit(i) = outa(i)      'Next      CopyMemory e_bit(0), outa(0), UBound(outa) + 1          End Sub                    '==========================================================================================     ' EncryptDes_ArrToArr 函数说明：     ' DES加/解密     ' 返回：     ' 无     ' 参数：     ' m_bit() As Byte 输入     ' e_bit() As Byte 输出 ,元素个数为8的倍数     ' bUseKeyNo As Byte 可选输入,为2则使用第二个密钥加/解密，否则使用第一个密钥加/解密     ' bFlag As Byte 可选输入,为2则解密,否则加密     '==========================================================================================     Sub EncryptDes_ArrToArr(m_bit() As Byte, e_bit() As Byte, Optional bUseKeyNo As Byte = 1, Optional bFlag As Byte = 1)      Dim iSL As Integer      Dim ina(7) As Byte      Dim lPos As Long      Dim outa(7) As Byte      Dim L As Long, M As Long      Dim i As Long           If bUseKeyNo <> 2 Then bUseKeyNo = 1           iSL = UBound(m_bit) + 1      If iSL Mod 8 <> 0 Then      iSL = ((iSL / 8) + 1) * 8      End If           ReDim e_bit(iSL - 1) As Byte      L = 0      Do While L <= UBound(m_bit)      M = L + 7      If M > UBound(m_bit) Then M = UBound(m_bit)      For i = 0 To 7      ina(i) = 0      Next      For i = L To M      ina(i - L) = m_bit(i)      Next                endes1 ina(), outa(), bUseKeyNo, bFlag                For i = 0 To 7      e_bit(i + L) = outa(i)      Next      L = L + 8      Loop     End Sub          '     '***************************************************************     '     '==================== 下面是私有函数及过程 ===================     '     '***************************************************************               '     '* ArrXor 函数说明：     '* 将输入的两个数组中的字节元素分别作异或运算     '* 返回：     '* 无     '* 参数：'     '* const BYTE in1[] 输入字符串1     '* const BYTE in2[] 输入字符串2     '* BYTE out[] 输出的结果字符串     '*/     Private Sub ArrXor(in1() As Byte, in2() As Byte, outa() As Byte)      Dim i As Integer      For i = 0 To UBound(in1)      outa(i) = in1(i) Xor in2(i)      Next     End Sub          '/*     ' * Bin2ASCII 函数说明：     ' * 将64字节的01字符串转换成对应的8个字节     ' * 返回：     ' * 转换后结果的指针     ' * 参数：     ' * const BYTE abyte(64) 输入字符串     ' * BYTE bit(8) 输出的转换结果     ' */     Private Sub Bin2ASCII(abyte() As Byte, bit() As Byte)      Dim i As Integer      For i = 0 To 7      bit(i) = abyte(i * 8) * 128 + abyte(i * 8 + 1) * 64 + _      abyte(i * 8 + 2) * 32 + abyte(i * 8 + 3) * 16 + _      abyte(i * 8 + 4) * 8 + abyte(i * 8 + 5) * 4 + _      abyte(i * 8 + 6) * 2 + abyte(i * 8 + 7)      Next     End Sub          '/*     ' * ASCII2Bin 函数说明：     ' * 将8个字节输入转换成对应的64字节的01字符串     ' * 返回：     ' * 转换后结果的指针     ' * 参数：     ' * const BYTE bit[8] 输入字符串     ' * BYTE byte[64] 输出的转换结果     ' */     Private Sub ASCII2Bin(bit() As Byte, abyte() As Byte)      Dim i As Integer, j As Integer      For i = 0 To 7      For j = 0 To 7      abyte(i * 8 + j) = (bit(i) / (2 ^ (7 - j))) And &H1      Next      Next     End Sub          '/*     ' * GenSubKey 函数说明：     ' * 由输入的密钥得到16个子密钥     ' * 返回：     ' * 无     ' * 参数：     ' * const BYTE oldkey[8] 输入密钥     ' * BYTE newkey[16][8] 输出的子密钥     ' */     Private Sub GenSubKey(oldkey() As Byte, newkey() As Byte)      Dim i As Integer, k As Integer, rol As Integer      Dim s As String           Dim oldkey_byte(63) As Byte ' BYTE oldkey_byte[64];      Dim oldkey_byte1(63) As Byte ' BYTE oldkey_byte1[64];      Dim oldkey_byte2(63) As Byte ' BYTE oldkey_byte2[64];      Dim oldkey_c(55) As Byte ' BYTE oldkey_c[56];      Dim oldkey_d(55) As Byte ' BYTE oldkey_d[56];      Dim newkey_byte(15, 63) As Byte ' BYTE newkey_byte[16][64];      Dim aT      Dim abyte(63) As Byte, bbyte(7) As Byte           rol = 0                     ASCII2Bin oldkey(), oldkey_byte()           '//位变换--根据换位表换位 压缩成56位密码      'for(i = 0; i < 56; i++)      ' oldkey_byte1[i] = oldkey_byte[pc_1[i] - 1];           For i = 0 To 55      oldkey_byte1(i) = oldkey_byte(pc_1(i) - 1)      Next                     '//分为左右两部分，复制一遍以便于循环左移      'for(i = 0; i < 28; i++)      ' oldkey_c[i] = oldkey_byte1[i], oldkey_c[i + 28] = oldkey_byte1[i],      ' oldkey_d[i] = oldkey_byte1[i + 28], oldkey_d[i + 28] = oldkey_byte1[i + 28];           'For i = 0 To 27      ' oldkey_c(i) = oldkey_byte1(i)      ' oldkey_c(i + 28) = oldkey_byte1(i)      ' oldkey_d(i) = oldkey_byte1(i + 28)      ' oldkey_d(i + 28) = oldkey_byte1(i + 28)      'Next      CopyMemory oldkey_c(0), oldkey_byte1(0), 28      CopyMemory oldkey_c(28), oldkey_byte1(0), 28      CopyMemory oldkey_d(0), oldkey_byte1(28), 28      CopyMemory oldkey_d(28), oldkey_byte1(28), 28           '//分别生成16个子密钥      'for(i = 0; i < 16; i++)      '{      ' //循环左移      ' rol += ccmovebit[i];      ' //合并左移后的结果      ' for(k = 0; k < 28; k++)      ' oldkey_byte2[k] = oldkey_c[k + rol], oldkey_byte2[k + 28] = oldkey_d[k + rol];      ' //位变换      ' for(k = 0; k < 48; k++)      ' newkey_byte[i][k] = oldkey_byte2[pc_2[k] - 1];      '}      For i = 0 To 15      '循环左移      rol = rol + ccmovebit(i)      '合并左移后的结果      'For k = 0 To 27      ' oldkey_byte2(k) = oldkey_c(k + rol)      ' oldkey_byte2(k + 28) = oldkey_d(k + rol)      'Next           CopyMemory oldkey_byte2(0), oldkey_c(rol), 28      CopyMemory oldkey_byte2(28), oldkey_d(rol), 28           '位变换      For k = 0 To 47      newkey_byte(i, k) = oldkey_byte2(pc_2(k) - 1)      Next      Next           '生成最终结果      'for(i = 0; i < 16; i++)      ' Bin2ASCII(newkey_byte[i], newkey[i]);      For i = 0 To 15      For k = 0 To 63      abyte(k) = newkey_byte(i, k)      Next                     Bin2ASCII abyte(), bbyte()      For k = 0 To 7      newkey(i, k) = bbyte(k)      Next      Next     End Sub               '/*     ' * endes1 函数说明：     ' * DES加密     ' * 返回：     ' * 无     ' * 参数：     ' * const BYTE m_bit[8] 输入的原文     ' * const BYTE k_bit[8] 输入的密钥     ' * BYTE e_bit[8] 输出的密文     ' bFlag=1 加 =2解     ' */     Private Sub endes1(m_bit() As Byte, e_bit() As Byte, Optional bUseKeyNo As Byte = 1, Optional bFlag As Byte = 1)           Dim s As String           Dim m_bit1(7) As Byte ' BYTE m_bit1[8] = {0};      Dim m_byte(63) As Byte ' BYTE m_byte[64] = {0};      Dim m_byte1(63) As Byte ' BYTE m_byte1[64] = {0};      'Dim key_n(15, 7) As Byte ' BYTE key_n[16][8] = {0};      Dim l_bit(16, 7) As Byte ' BYTE l_bit[17][8] = {0};      Dim r_bit(16, 7) As Byte ' BYTE r_bit[17][8] = {0};      Dim e_byte(63) As Byte ' BYTE e_byte[64] = {0};      Dim e_byte1(63) As Byte ' BYTE e_byte1[64] = {0};      Dim r_byte(63) As Byte ' BYTE r_byte[64] = {0};      Dim r_byte1(63) As Byte ' BYTE r_byte1[64] = {0};      Dim key_n           Dim l_bit0(7) As Byte, r_bit0(7) As Byte      Dim l_bit1(7) As Byte, r_bit1(7) As Byte           Dim abyte8(7) As Byte                Dim i As Integer, j As Integer, k As Integer           If bUseKeyNo <> 2 Then bUseKeyNo = 1           If bUseKeyNo = 1 Then key_n = key_n1 Else key_n = key_n2                '//根据密钥生成16个子密钥      'GenSubKey k_bit(), key_n()           '//将待加密字串变换成01串      ASCII2Bin m_bit(), m_byte()           '//按照ip表对待加密字串进行位变换      'for(i = 0; i < 64; i++)      ' m_byte1[i] = m_byte[ip[i] - 1];      For i = 0 To 63      m_byte1(i) = m_byte(ip(i) - 1)      Next           '位变换后的待加密字串      Bin2ASCII m_byte1(), m_bit1()           '//将位变换后的待加密字串分成两组，分别为前4字节L和后4字节R，作为迭代的基础（第0次迭代）      'for(i = 0; i < 4; i++)      ' l_bit[0][i] = m_bit1[i], r_bit[0][i] = m_bit1[i + 4];      For i = 0 To 3      'l_bit(0, i) = m_bit1(i)      'r_bit(0, i) = m_bit1(i + 4)      CopyMemory l_bit0(0), m_bit1(0), 4      CopyMemory r_bit0(0), m_bit1(4), 4      Next           '//16次迭代运算      'for(i = 1; i <= 16; i++)           For i = 1 To 16      '//R的上一次的迭代结果作为L的当前次迭代结果      'for(j = 0; j < 4; j++)      ' l_bit[i][j] = r_bit[i-1][j];      'For j = 0 To 3      ' l_bit(i, j) = r_bit(i - 1, j)      'Next      CopyMemory l_bit1(0), r_bit0(0), 4           'ASCII2Bin(r_bit[i-1], r_byte);      'For j = 0 To 7      ' abyte8(j) = r_bit(i - 1, j)      'Next      CopyMemory abyte8(0), r_bit0(0), 8           ASCII2Bin abyte8(), r_byte()           '//将R的上一次迭代结果按E表进行位扩展得到48位中间结果      'for(j = 0; j < 48; j++)      ' r_byte1[j] = r_byte[e[j] - 1];      'Bin2ASCII(r_byte1, r_bit[i-1]);      For j = 0 To 47      r_byte1(j) = r_byte(e(j) - 1)      Next      Bin2ASCII r_byte1(), abyte8()      'For j = 0 To 7      ' r_bit(i - 1, j) = abyte8(j)      'Next      CopyMemory r_bit0(0), abyte8(0), 8           '//与第I-1个子密钥进行异或运算      'for(j = 0; j < 6; j++)      ' r_bit[i-1][j] = r_bit[i-1][j] ^ key_n[i-1][j];      For j = 0 To 5      If bFlag = 1 Then      '加      'r_bit(i - 1, j) = r_bit(i - 1, j) Xor key_n(i - 1, j)      r_bit0(j) = r_bit0(j) Xor key_n(i - 1, j)      Else      '解      'r_bit(i - 1, j) = r_bit(i - 1, j) Xor key_n((17 - i) - 1, j)      r_bit0(j) = r_bit0(j) Xor key_n((17 - i) - 1, j)      End If      Next           '//进行S选择，得到32位中间结果      'SReplace(r_bit[i - 1]);      'For j = 0 To 7      ' abyte8(j) = r_bit(i - 1, j)      'Next      CopyMemory abyte8(0), r_bit0(0), 8           SReplace abyte8()      'For j = 0 To 7      ' r_bit(i - 1, j) = abyte8(j)      'Next      CopyMemory r_bit0(0), abyte8(0), 8           '//结果与L的上次迭代结果异或得到R的此次迭代结果      'for(j = 0; j < 4; j++)      '{      ' r_bit[i][j] = l_bit[i-1][j] ^ r_bit[i-1][j];      '}      For j = 0 To 3      'r_bit(i, j) = l_bit(i - 1, j) Xor r_bit(i - 1, j)      r_bit1(j) = l_bit0(j) Xor r_bit0(j)      Next           CopyMemory l_bit0(0), l_bit1(0), 8      CopyMemory r_bit0(0), r_bit1(0), 8      Next                '//组合最终迭代结果      'for(i = 0; i < 4; i++)      ' e_bit[i] = r_bit[16][i], e_bit[i + 4] = l_bit[16][i];      'For i = 0 To 3      ' e_bit(i) = r_bit(16, i)      ' e_bit(i + 4) = l_bit(16, i)      'Next      CopyMemory e_bit(0), r_bit1(0), 4      CopyMemory e_bit(4), l_bit1(0), 4           ASCII2Bin e_bit(), e_byte()           '//按照表IP-1进行位变换      'for(i = 0; i < 64; i++)      ' e_byte1[i] = e_byte[ip_1[i] - 1];      For i = 0 To 63      e_byte1(i) = e_byte(ip_1(i) - 1)      Next           '//得到最后的加密结果      Bin2ASCII e_byte1(), e_bit()     End Sub                         '/*     ' * SReplace 函数说明：     ' * S选择     ' * 返回：     ' * 无     ' * 参数：     ' * BYTE s_bit[8] 输入暨选择后的输出     ' */     Private Sub SReplace(s_bit() As Byte)           Dim i As Integer                Dim s_byte(63) As Byte ' BYTE s_byte[64] = {0};      Dim s_byte1(63) As Byte ' BYTE s_byte1[64] = {0};      Dim row As Byte, col As Byte      Dim s_out_bit(7) As Byte 'BYTE s_out_bit[8] = {0};                          row = 0: col = 0           '//转成二进制字符串处理      ASCII2Bin s_bit(), s_byte()      'for(int i = 0; i < 8; i++)      '{      ' //0、5位为row，1、2、3、4位为col，在S表中选择一个八位的数      ' row = s_byte[i * 6] * 2 + s_byte[i * 6 + 5];      ' col = s_byte[i * 6 + 1] * 8 + s_byte[i * 6 + 2] * 4 + s_byte[i * 6 + 3] * 2 + s_byte[i * 6 + 4];      ' s_out_bit[i] = s[i][row][col];      '}      For i = 0 To 7      '0、5位为row，1、2、3、4位为col，在S表中选择一个八位的数      row = s_byte(i * 6) * 2 + s_byte(i * 6 + 5)      col = s_byte(i * 6 + 1) * 8 + s_byte(i * 6 + 2) * 4 + s_byte(i * 6 + 3) * 2 + s_byte(i * 6 + 4)      s_out_bit(i) = ss(i, row, col)      Next           '//将八个选择的八位数据压缩表示      's_out_bit[0] = (s_out_bit[0] << 4) + s_out_bit[1];      's_out_bit[1] = (s_out_bit[2] << 4) + s_out_bit[3];      's_out_bit[2] = (s_out_bit[4] << 4) + s_out_bit[5];      's_out_bit[3] = (s_out_bit[6] << 4) + s_out_bit[7];      s_out_bit(0) = s_out_bit(0) * (2 ^ 4) + s_out_bit(1)      s_out_bit(1) = s_out_bit(2) * (2 ^ 4) + s_out_bit(3)      s_out_bit(2) = s_out_bit(4) * (2 ^ 4) + s_out_bit(5)      s_out_bit(3) = s_out_bit(6) * (2 ^ 4) + s_out_bit(7)           '//转成二进制字符串处理      ASCII2Bin s_out_bit(), s_byte()           '//换位      'for(i = 0; i < 32; i++)      ' s_byte1[i] = s_byte[p[i] - 1];      For i = 0 To 31      s_byte1(i) = s_byte(p(i) - 1)      Next           '//生成最后结果      Bin2ASCII s_byte1(), s_bit()          End Sub                              Private Sub Class_Initialize()      Dim i As Integer, j As Integer, k As Integer, L As Integer      Dim aT, s As String      '//换位表IP      s = "58,50,42,34,26,18,10,2," & _      "60,52,44,36,28,20,12,4," & _      "62,54,46,38,30,22,14,6," & _      "64,56,48,40,32,24,16,8," & _      "57,49,41,33,25,17,9,1," & _      "59,51,43,35,27,19,11,3," & _      "61,53,45,37,29,21,13,5," & _      "63,55,47,39,31,23,15,7"      aT = Split(s, ",")      For i = 0 To 63: ip(i) = Val(aT(i)): Next           '//换位表IP_1      s = "40,8,48,16,56,24,64,32," & _      "39,7,47,15,55,23,63,31," & _      "38,6,46,14,54,22,62,30," & _      "37,5,45,13,53,21,61,29," & _      "36,4,44,12,52,20,60,28," & _      "35,3,43,11,51,19,59,27," & _      "34,2,42,10,50,18,58,26," & _      "33,1,41,9,49,17,57,25"      aT = Split(s, ",")      For i = 0 To 63: ip_1(i) = Val(aT(i)): Next           '//放大换位表      s = "32,1, 2, 3, 4, 5," & _      "4, 5, 6, 7, 8, 9," & _      "8, 9, 10,11,12,13," & _      "12,13,14,15,16,17," & _      "16,17,18,19,20,21," & _      "20,21,22,23,24,25," & _      "24,25,26,27,28,29," & _      "28,29,30,31,32,1"      aT = Split(s, ",")      For i = 0 To 47: e(i) = Val(aT(i)): Next                '缩小换位表1      s = "57,49,41,33,25,17,9," & _      "1,58,50,42,34,26,18," & _      "10,2,59,51,43,35,27," & _      "19,11,3,60,52,44,36," & _      "63,55,47,39,31,23,15," & _      "7,62,54,46,38,30,22," & _      "14,6,61,53,45,37,29," & _      "21,13,5,28,20,12,4"      aT = Split(s, ",")      For i = 0 To 55: pc_1(i) = Val(aT(i)): Next                '//缩小换位表2      s = "14,17,11,24,1,5," & _      "3,28,15,6,21,10," & _      "23,19,12,4,26,8," & _      "16,7,27,20,13,2," & _      "41,52,31,37,47,55," & _      "30,40,51,45,33,48," & _      "44,49,39,56,34,53," & _      "46,42,50,36,29,32"      aT = Split(s, ",")      For i = 0 To 47: pc_2(i) = Val(aT(i)): Next           '//16次循环左移对应的左移位数      s = "1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1"      aT = Split(s, ",")      For i = 0 To 15: ccmovebit(i) = Val(aT(i)): Next                s = "16,7,20,21," & _      "29,12,28,17," & _      "1,15,23,26," & _      "5,18,31,10," & _      "2,8,24,14," & _      "32,27,3,9," & _      "19,13,30,6," & _      "22,11,4,25"      aT = Split(s, ",")      For i = 0 To 31      p(i) = Val(aT(i))      Next           s = "14,4,13,1,2,15,11,8,3,10,6,12,5,9,0,7," & _      "0,15,7,4,14,2,13,1,10,6,12,11,9,5,3,8," & _      "4,1,14,8,13,6,2,11,15,12,9,7,3,10,5,0," & _      "15,12,8,2,4,9,1,7,5,11,3,14,10,0,6,13," & _      "15,1,8,14,6,11,3,4,9,7,2,13,12,0,5,10," & _      "3,13,4,7,15,2,8,14,12,0,1,10,6,9,11,5," & _      "0,14,7,11,10,4,13,1,5,8,12,6,9,3,2,15," & _      "13,8,10,1,3,15,4,2,11,6,7,12,0,5,14,9," & _      "10,0,9,14,6,3,15,5,1,13,12,7,11,4,2,8," & _      "13,7,0,9,3,4,6,10,2,8,5,14,12,11,15,1," & _      "13,6,4,9,8,15,3,0,11,1,2,12,5,10,14,7," & _      "1,10,13,0,6,9,8,7,4,15,14,3,11,5,2,12," & _      "7,13,14,3,0,6,9,10,1,2,8,5,11,12,4,15," & _      "13,8,11,5,6,15,0,3,4,7,2,12,1,10,14,9," & _      "10,6,9,0,12,11,7,13,15,1,3,14,5,2,8,4," & _      "3,15,0,6,10,1,13,8,9,4,5,11,12,7,2,14,"           s = s & _      "2,12,4,1,7,10,11,6,8,5,3,15,13,0,14,9," & _      "14,11,2,12,4,7,13,1,5,0,15,10,3,9,8,6," & _      "4,2,1,11,10,13,7,8,15,9,12,5,6,3,0,14," & _      "11,8,12,7,1,14,2,13,6,15,0,9,10,4,5,3," & _      "12,1,10,15,9,2,6,8,0,13,3,4,14,7,5,11," & _      "10,15,4,2,7,12,9,5,6,1,13,14,0,11,3,8," & _      "9,14,15,5,2,8,12,3,7,0,4,10,1,13,11,6," & _      "4,3,2,12,9,5,15,10,11,14,1,7,6,0,8,13," & _      "4,11,2,14,15,0,8,13,3,12,9,7,5,10,6,1," & _      "13,0,11,7,4,9,1,10,14,3,5,12,2,15,8,6," & _      "1,4,11,13,12,3,7,14,10,15,6,8,0,5,9,2," & _      "6,11,13,8,1,4,10,7,9,5,0,15,14,2,3,12," & _      "13,2,8,4,6,15,11,1,10,9,3,14,5,0,12,7," & _      "1,15,13,8,10,3,7,4,12,5,6,11,0,14,9,2," & _      "7,11,4,1,9,12,14,2,0,6,10,13,15,3,5,8," & _      "2,1,14,7,4,10,8,13,15,12,9,0,3,5,6,11"      aT = Split(s, ",")      L = 0      For i = 0 To 7      For j = 0 To 3      For k = 0 To 15      ss(i, j, k) = Val(aT(L))      L = L + 1      Next      Next      Next          End Sub
展开全文
• VB加密解密算法，VB编程原码，用于用户制作程序加密内容
• vb6的各种加密算法，外国朋友写的。大家可以测试一下。
• VB54种加密算法 1
• VB 序列号加密算法。在网上下载别人的。不是自己写的。上传的目的是为了获得积分
• vb 密码单向加密算法rar,vb 密码单向加密算法
• 字节逐位倒排序加密法是以比特为单位的换位加密方法，用VB实现的具体算法是： (1) 以二进制模式打开源文件； (2) 从源文件第I位读取一个字节，假设为字母“A”，得到“A”的ASCII值为65； (3) 将65转换成八位二...

编写一个加密软件，要求将源文件按字节逐位倒排序加密法加密。
字节逐位倒排序加密法是以比特为单位的换位加密方法，用VB实现的具体算法是：
(1) 以二进制模式打开源文件；
(2) 从源文件第I位读取一个字节，假设为字母“A”，得到“A”的ASCII值为65；
(3) 将65转换成八位二进制串为“01000001”；
(4) 将“01000001”按字节逐位倒排序得另一个八位二进制串“10000010”；
(5) 将“10000010”转换成十进制再写回源文件第I位置，完成一个字节的加密；
(6) 重复(2)、(3)、(4)和(5)，直到所有字节加密结束。
为了使程序模块化，我们用函数过程ByteToBin完成将字节型数据转换成二进制串（其实质就是将十进制数转换成八位二进制串）；用函数过程BinToByte将二进制串转换成字节型数据（实质是将八位二进制串转换成十进制数）：用函数过程Reverse将八位二进制串逐位倒排序。具体程序如下：
Function ByteToBin(m As Byte) As String   ' 将字节型数据转换成八位二进制字符串
Dim c$c$ = ""
Do While m <> 0
r = m Mod 2
m = m \ 2
c$= r & c$
Loop
c$= Right("00000000" & c$, 8)
ByteToBin = c$End Function Function Reverse(m As String) As String ' 将八位二进制字符串颠倒顺序 Dim i%, x$
x = ""
For i = 1 To 8
x = Mid(m, i, 1) & x
Next i
Reverse = x
End Function
Function BinToByte(m As String) As Byte     ' 将八位二进制串转换成十进制
Dim x As String * 1, y%, z%
z = 0
For i = 1 To 8
x = Mid(m, i, 1)
y = x * 2 ^ (8 - i)
z = z + y
Next i
BinToByte = z
End Function
Private Sub Command1_Click()
Dim x As Byte, i%, fname\$
fname = InputBox("请输入要加密的文件名！注意加上路径名：")
If Dir(fname) = "" Then
MsgBox "文件不存在！"
Exit Sub
End If
Open fname For Binary As #1         ' 以二进制访问模式打开待加密文件
For i = 1 To LOF(1)               ' LOF函数是求文件长度的内部函数
Get #1, i, x                 ' 取出第i个字节
x = BinToByte(Reverse(ByteToBin(x))) ' 这里调用了三个自定义函数
Put #1, i, x                 ' 将加密后的这个字节写回到文件原位置
Next i
Close
MsgBox "任务完成！"
End Sub
本例可以完成对任意文件的加密与解密，对同一文件作第一次处理为加密，第二次处理为解密。要调试本程序，可用记事本在C盘根目录下任意建立一个文本文件（假设为文件名为aaa.txt），其中的内容任意（可以包括字母、汉字、数字、回车符、换行符等）。运行本程序后，在输入文件名的对话框中输入文件名（如：“C:\aaa.txt”）后回车，即可完成对文件的加密。文件加密后，可以在记事本中打开该文件查看加密效果。如果想解密，可再次运行该程序并输入相同文件名。

转载于:https://www.cnblogs.com/iseaside/p/3501082.html
展开全文
• VB.NET关于加密算法的详细介绍 加密将防止数据被查看或修改，并在原本不安全的信道上提供安全的通信信道，它达到以下目的： 　保密性：防止用户的标识或数据被读取。 　数据完整性：防止数据被更改。 　身份验证...
• RSA加密算法在VBRSA加密算法在VBRSA加密算法VB
• MD5加密算法vb源码 MD5加密算法vb源码 MD5加密算法vb源码
• vbMD5加密算法-vbMD5加密算法vbMD5加密算法-vbMD5加密算法vbMD5加密算法-vbMD5加密算法vbMD5加密算法-vbMD5加密算法
• VB的SHA加密算法类模块,可以直接使用。
• VB6-AES加密算法源码，无错，可直接运行。密钥长度支持128 Bit,192 Bit,256 Bit。支持字符串加密和文件加密。
• vb写的md5加密算法,希望对大家有帮助吧
• VB.Net实现des加密算法的实例 对于加密算法研究的朋友或许能够得到帮助
• 数据加密技术及用VB6.0实现数据加密算法
• 加密算法模块, 直接导入程序调用就可以了,意思一下就一分.
• MD5加密算法vb语法，有兴趣的可以下去，可以直接调用
• 在使用VB6.0软件编程过程中，收集了各种VB源码实例进行测试，然后按照自己的需要进行编辑整理。这里AES加密算法,适合新学者和初次编程人员进行参考。
• ## AES加密算法VB版本

热门讨论 2008-04-16 17:27:02
不同于其他区段加密算法，AES是在VB中是最有效率的，因为加密一个区段能被使用唯一的CopyMemory，异或操作和一些位掩码。这个类模块可以支持所有的密钥和字区大小。并且难能可贵的是支持中英文混合加密。
• 摘要:VB源码,加密解密,AES,字符串...　AES加密算法VB源码演示程序，涉及加密算法以及文件加密、解密，在多种场合中都可应用，本加密程序可以加密字符和加密文件，当然也可解密，对学习AES算法当然是挺有参考意义的。
• MD5加密算法,此算法是不可逆的,因此加密强度高,不容易破解.
• RC4经典加密算法(VB代码).pdf

...