Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
  3. (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  4. Private Declare Function ReleaseCapture Lib "user32" () As Long
  5.  
  6. Const WM_NCLBUTTONDOWN = &HA1
  7. Const HTCAPTION = 2
  8.  
  9.  
  10.  
  11. 'Dim Key As Integer 'пометка ключ
  12. Dim mainpath, mainpath1 As String
  13. Dim fnikki As Integer
  14.  
  15. 'Private Sub Command1_Click()
  16. 'Dim MyLine As String
  17. 'Open mainpath For Input As #1
  18. '    Do While Not EOF(1)
  19. '        Line Input #1, MyLine
  20. '        deb.Text = MyLine
  21. '        txtput.Text = MyLine
  22. '    Loop
  23. 'Close #1
  24. 'txtput.Text = Decrypt(txtput.Text, 15)
  25. 'txtput.Text = Decrypt(txtput.Text, kkey.Text)
  26. 'End Sub
  27.  
  28. Private Sub Command2_Click()
  29. txtput.Text = txtput.Text & vbCrLf & "[" & Time & "   " & Date & "]"
  30. End Sub
  31.  
  32. Private Sub Command3_Click()
  33. End
  34. End Sub
  35.  
  36. Private Sub Form_Load()
  37. 'Debug.Print "copy " & App.Path & "\nikki.txt " & App.Path & "\backup_nikki.txt"
  38. mainpath = App.Path & "/nikki.txt"
  39. mainpath1 = App.Path
  40. 'FileCopy App.Path & "\nikki.txt", App.Path & "\backup_nikki.txt"
  41.  
  42. Close #fnikki
  43. 'Key = 15 '
  44.  
  45.  
  46. End Sub
  47.  
  48.  
  49. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  50. Call ReleaseCapture
  51. Call SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
  52. End Sub
  53.  
  54. Private Sub wr_Click()
  55. 'Dim cry As String
  56. 'cry = txtput.Text
  57.  
  58.  
  59.     Dim oTest           As CRijndael
  60.     Dim sTemp           As String
  61.     Dim bytIn()         As Byte
  62.     Dim bytOut()        As Byte
  63.     Dim bytPassword()   As Byte
  64.     Dim bytClear()      As Byte
  65.     Dim lCount          As Long
  66.     Dim lLength         As Long
  67.    
  68.     Set oTest = New CRijndael
  69.    
  70.     ' Do a quick and dirty conversion of message and password to byte arrays, as the
  71.    ' string is Unicode we will get two bytes per character. You might want to loop through
  72.    ' instead if you are only dealing in ASCII using the ASC() function so you get one
  73.    ' byte per character.
  74.    ' NOTE: You need to be very careful here if you are encrypting on a system
  75.    ' with one character set and then expecting to decrypt on a different system
  76.    ' with a different character set (e.g. Japanese to US English). It will not be
  77.    ' a problem if you are only using the ASCII range 0-127, but remember, we are
  78.    ' encrypting/decrypting bytes not characters, the byte encryption/decryption
  79.    ' will be correct, but your conversion between bytes and characters needs to be
  80.    ' tested out.
  81.    bytIn = txtput.Text
  82.     bytPassword = kkey.Text
  83.    
  84.     ' This is the alternate way for single bytes...
  85. '    sTemp = txtPlain.Text
  86. '    lLength = Len(sTemp)
  87. '    ReDim bytIn(lLength - 1)
  88. '    For lCount = 1 To lLength
  89. '        bytIn(lCount - 1) = AscB(Mid(sTemp, lCount, 1))
  90. '    Next
  91. '    sTemp = txtKey.Text
  92. '    lLength = Len(sTemp)
  93. '    ReDim bytPassword(lLength - 1)
  94. '    For lCount = 1 To lLength
  95. '        bytPassword(lCount - 1) = AscB(Mid(sTemp, lCount, 1))
  96. '    Next
  97.    
  98.     ' Encrypt the data
  99.    bytOut = oTest.EncryptData(bytIn, bytPassword)
  100.  
  101.  
  102. Dim fnikki As Integer
  103. fnikki = FreeFile
  104. Open mainpath For Binary As #fnikki
  105. 'put0 = Encrypt(txtput.Text, 15)
  106. Put #fnikki, , bytOut
  107. Close #fnikki
  108.        
  109. End Sub
  110.  
  111. Private Sub rd_Click()
  112.  
  113.     Dim oTest           As CRijndael
  114.     Dim sTemp           As String
  115.     Dim bytIn()         As Byte
  116.     Dim bytOut()        As Byte
  117.     Dim bytPassword()   As Byte
  118.     Dim bytClear()      As Byte
  119.     Dim lCount          As Long
  120.     Dim lLength         As Long
  121.    
  122.     Set oTest = New CRijndael
  123.    
  124. Dim bData() As Byte
  125.  
  126. Open mainpath For Binary As #1
  127.  
  128. If LOF(1) > 0 Then
  129.             ' Decrypt
  130.            
  131.     ReDim bData(LOF(1) - 1)
  132.    
  133.     Get #1, , bData()
  134.    
  135.     bytClear = oTest.DecryptData(bData(), kkey.Text)
  136.    
  137.     ' Quick and dirty conversion back to a string. If we earlier looped using the ASC() function
  138.    ' to get one byte per character, we will now need to do the opposite and loop using
  139.    ' the CHR() function to put the string back together again.
  140.    'txtPlainAgain.Text = bytClear
  141.    txtput.Text = bytClear
  142.     ' This is the alternate way for single bytes...
  143. '    lLength = UBound(bytClear) + 1
  144. '    sTemp = String(lLength, " ")
  145. '    For lCount = 1 To lLength
  146. '        Mid(sTemp, lCount, 1) = Chr(bytClear(lCount - 1))
  147. '    Next
  148. '    txtPlainAgain.Text = sTemp
  149.        deb.Text = "*** DEBUG" & vbCrLf & txtput.Text
  150.        
  151. End If
  152.  
  153. Close #1
  154.  
  155. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement