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

📄 crypt.bas

📁 测试Linux从2.4内核开始就非常好的支持了网桥
💻 BAS
字号:
'general sectionDeclare Function GetPrivateProfileInt% Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName$, ByVal nDefault%, ByVal lpFileName$)Declare Function GetPrivateProfileString% Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName As Any, ByVal lpDefault$, ByVal lpReturnedString$, ByVal nSize%, ByVal lpFileName$)Declare Function WritePrivateProfileString% Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName$, ByVal lpString$, ByVal lplFileName$)'Call the Crypt routine again the decrypt the Strg$.  Without the proper'Pass$, you'll get garbage back.  The longer the password, the longer it'takes to "number crunch" to figure out the password.Dim Pass$Dim Strg$Dim H$Sub Command1_Click ()    Pass$ = "PASSWORD"    Strg$ = "You won't crack this easily"    Print "Original = "; Strg$    Call Crypt(Pass$, Strg$)    Print "Encrypted = "; Strg$'When writing an encrypted password to a sequential access file like the'INI files, you need to convert the resultant encrypted file to hex data.'This is because you can end up with an encrypted password that contains'characters which cannot be properly read using sequential access.  So,'before saving your encrypted password, use this routine:H$ = ""For i = 1 To Len(Strg$)   J$ = Hex$(Asc(Mid$(Strg$, i, 1)))   If Len(J$) = 1 Then J$ = "0" + J$   H$ = H$ + J$Next   Print "Hex = "; H$'This will create a string like "0EF31105" or some such.  Save that to'the INI file.'Store the LENGTH of the password string as 2 bytes and concatenate   H$ = Format$(Len(H$), "00") + H$   x% = WritePrivateProfileString%("SECURITY", "PASSWORD", H$, "E:\PROJECT.INI")End SubSub Command2_Click ()'To read it back in,  H$ = Space$(80)  x% = GetPrivateProfileString%("SECURITY", "PASSWORD", "PASSWORD", H$, Len(H$), "E:\PROJECT.INI")  Print "After INI read = "; H$ 'PASSWORD=160000000000000000  H$ = Mid$(H$, 3, Val(Left$(H$, 2)))  Print "Before hex conversion = "; H$Strg$ = ""For i = 1 To Len(H$) Step 2   J$ = Mid$(H$, i, 2)   Strg$ = Strg$ + Chr$(Val("&H" + J$))Next   Print "After hex conversion = "; Strg$'Strg$ would then contain the encrypted string, which you can now'decrypt.    Call Crypt(Pass$, Strg$)    Print "Decrypted = "; Strg$End SubSub Crypt (Pass$, Strg$)  a = 1  For i = 1 To Len(Strg$)     B = Asc(Mid$(Pass$, a, 1)): a = a + 1: If a > Len(Pass$) Then a = 1     Mid$(Strg$, i, 1) = Chr$(Asc(Mid$(Strg$, i, 1)) Xor B)  NextEnd Sub

⌨️ 快捷键说明

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