Ver- und Entschlüsselung

    • VB6

      Ver- und Entschlüsselung

      Um eine Datei zu verschlüsseln dann schau hier rein vbarchiv.net/download/download_detail.php?pid=362

      Text in TextBox Ver/entschlüsseln

      Visual Basic-Quellcode

      1. Public Function EncodeString(ByVal strToEncode As String, _
      2. ByVal strPassword As String) As String
      3. Dim strResult As String
      4. Dim i As Long
      5. Dim cfc() As Integer
      6. ReDim cfc(1 To Len(strPassword))
      7. For i = 1 To UBound(cfc)
      8. cfc(i) = Asc(Right(strPassword, _
      9. Len(strPassword) - i + 1))
      10. Next i
      11. For i = 1 To Len(strToEncode)
      12. strResult = strResult & _
      13. Chr(addToIndex(Asc(Right(strToEncode, _
      14. Len(strToEncode) - i + 1)), VirtPos(i, cfc)))
      15. Next i
      16. EncodeString = strResult
      17. End Function
      18. ' Text in Verbindung mit einem Passwort entschlüsseln
      19. Public Function DecodeString(ByVal strToDecode As String, _
      20. ByVal strPassword As String) As String
      21. Dim strResult As String
      22. Dim i As Long
      23. Dim cfc() As Integer
      24. ReDim cfc(1 To Len(strPassword))
      25. ReDim ttc(1 To Len(strToDecode))
      26. For i = 1 To UBound(cfc)
      27. cfc(i) = Asc(Right(strPassword, _
      28. Len(strPassword) - i + 1))
      29. Next i
      30. For i = 1 To Len(strToDecode)
      31. strResult = strResult & _
      32. Chr(GetOfIndex(Asc(Right(strToDecode, _
      33. Len(strToDecode) - i + 1)), VirtPos(i, cfc)))
      34. Next i
      35. DecodeString = strResult
      36. End Function
      37. ' Hilfsfunktionen
      38. Private Function VirtPos(i As Long, _
      39. a() As Integer) As Integer
      40. If i > UBound(a) Then
      41. VirtPos = VirtPos(i - UBound(a), a)
      42. Else
      43. VirtPos = a(i)
      44. End If
      45. End Function
      46. Private Function addToIndex(i As Integer, _
      47. j As Integer) As Integer
      48. If i + j > 255 Then
      49. addToIndex = i + j - 255
      50. Else
      51. addToIndex = i + j
      52. End If
      53. End Function
      54. Private Function GetOfIndex(i As Integer, _
      55. j As Integer) As Integer
      56. If i - j < 0 Then
      57. GetOfIndex = i - j + 255
      58. Else
      59. GetOfIndex = i - j
      60. End If
      61. End Function
      62. ____________________________________________________________
      63. rivate Sub cmdEncode_Click()
      64. ' Verschlüsseln
      65. txtResult.Text = EncodeString(txtToEncode.Text, _
      66. txtPassword.Text)
      67. End Sub
      68. Private Sub cmdDecode_Click()
      69. ' Entschlüsseln
      70. txtResult.Text = DecodeString(txtResult.Text, _
      71. txtPassword.Text)


      4 Datei Eigenschaften auslesen

      Visual Basic-Quellcode

      1. ' zunächst die benötigten API-Deklarationen Private Declare Function ShellExecuteEx Lib "shell32.dll" _ (LPSHELLEXECUTEINFO As SHELLEXECUTEINFO) As Long Private Type SHELLEXECUTEINFO cbSize As Long fMask As Long hWnd As Long lpVerb As String lpFile As String lpParameters As String lpDirectory As String nShow As Long hInstApp As Long lpIDList As Long lpClass As String hkeyClass As Long dwHotKey As Long hIcon As Long hProcess As Long End Type Private Const SEE_MASK_FLAG_NO_UI = &H400 Private Const SEE_MASK_INVOKEIDLIST = &HC Private Const SEE_MASK_NOCLOSEPROCESS = &H40 ' Datei-Eigenschaften Dialog anzeigen Public Sub ShowFileInfoDlg(ByVal hWnd As Long, _ ByVal sFilename As String) Dim FILEINFO As SHELLEXECUTEINFO With FILEINFO .cbSize = Len(FILEINFO) .fMask = SEE_MASK_FLAG_NO_UI Or _ SEE_MASK_INVOKEIDLIST Or _ SEE_MASK_NOCLOSEPROCESS .hWnd = hWnd .lpVerb = "properties" .lpFile = sFileName End With Call ShellExecuteEx(FILEINFO) End Sub

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Agent“ ()