home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / A_SINE256_2053303122007.psc / MainFrm.frm < prev    next >
Text File  |  2007-03-12  |  30KB  |  761 lines

  1. VERSION 5.00
  2. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "richtx32.ocx"
  3. Object = "{65E121D4-0C60-11D2-A9FC-0000F8754DA1}#2.0#0"; "mschrt20.ocx"
  4. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  5. Begin VB.Form MainFrm 
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "SINE256 Visualisation And Sample Console"
  8.    ClientHeight    =   7770
  9.    ClientLeft      =   150
  10.    ClientTop       =   720
  11.    ClientWidth     =   13470
  12.    Icon            =   "MainFrm.frx":0000
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   7770
  17.    ScaleWidth      =   13470
  18.    StartUpPosition =   3  'Windows Default
  19.    Begin MSChart20Lib.MSChart CryptChart 
  20.       Height          =   3015
  21.       Left            =   6240
  22.       OleObjectBlob   =   "MainFrm.frx":030A
  23.       TabIndex        =   6
  24.       Top             =   5160
  25.       Width           =   7335
  26.    End
  27.    Begin MSChart20Lib.MSChart TextChart 
  28.       Height          =   3135
  29.       Left            =   6240
  30.       OleObjectBlob   =   "MainFrm.frx":2C65
  31.       TabIndex        =   5
  32.       Top             =   2280
  33.       Width           =   7335
  34.    End
  35.    Begin MSChart20Lib.MSChart AlgoChart 
  36.       Height          =   3135
  37.       Left            =   6240
  38.       OleObjectBlob   =   "MainFrm.frx":55C1
  39.       TabIndex        =   7
  40.       Top             =   -240
  41.       Width           =   7335
  42.    End
  43.    Begin MSComDlg.CommonDialog Dlg 
  44.       Left            =   6240
  45.       Top             =   480
  46.       _ExtentX        =   847
  47.       _ExtentY        =   847
  48.       _Version        =   393216
  49.    End
  50.    Begin VB.Frame Frame1 
  51.       Caption         =   "Statistic (Time in millisecond for each action)"
  52.       BeginProperty Font 
  53.          Name            =   "Verdana"
  54.          Size            =   8.25
  55.          Charset         =   0
  56.          Weight          =   400
  57.          Underline       =   0   'False
  58.          Italic          =   0   'False
  59.          Strikethrough   =   0   'False
  60.       EndProperty
  61.       Height          =   2175
  62.       Left            =   120
  63.       TabIndex        =   12
  64.       Top             =   2400
  65.       Width           =   6015
  66.       Begin VB.Label Label7 
  67.          Caption         =   "String to byte convertion :"
  68.          BeginProperty Font 
  69.             Name            =   "Verdana"
  70.             Size            =   8.25
  71.             Charset         =   0
  72.             Weight          =   400
  73.             Underline       =   0   'False
  74.             Italic          =   0   'False
  75.             Strikethrough   =   0   'False
  76.          EndProperty
  77.          Height          =   255
  78.          Left            =   120
  79.          TabIndex        =   20
  80.          Top             =   360
  81.          Width           =   2295
  82.       End
  83.       Begin VB.Label Label8 
  84.          Alignment       =   2  'Center
  85.          Caption         =   "Encrypt/Decrypt time :"
  86.          BeginProperty Font 
  87.             Name            =   "Verdana"
  88.             Size            =   8.25
  89.             Charset         =   0
  90.             Weight          =   400
  91.             Underline       =   0   'False
  92.             Italic          =   0   'False
  93.             Strikethrough   =   0   'False
  94.          EndProperty
  95.          Height          =   255
  96.          Left            =   360
  97.          TabIndex        =   19
  98.          Top             =   840
  99.          Width           =   2055
  100.       End
  101.       Begin VB.Label Label9 
  102.          Caption         =   "Byte to String convertion :"
  103.          BeginProperty Font 
  104.             Name            =   "Verdana"
  105.             Size            =   8.25
  106.             Charset         =   0
  107.             Weight          =   400
  108.             Underline       =   0   'False
  109.             Italic          =   0   'False
  110.             Strikethrough   =   0   'False
  111.          EndProperty
  112.          Height          =   255
  113.          Left            =   120
  114.          TabIndex        =   18
  115.          Top             =   1320
  116.          Width           =   2295
  117.       End
  118.       Begin VB.Label Label10 
  119.          Caption         =   "Display Data :"
  120.          BeginProperty Font 
  121.             Name            =   "Verdana"
  122.             Size            =   8.25
  123.             Charset         =   0
  124.             Weight          =   400
  125.             Underline       =   0   'False
  126.             Italic          =   0   'False
  127.             Strikethrough   =   0   'False
  128.          EndProperty
  129.          Height          =   255
  130.          Left            =   1200
  131.          TabIndex        =   17
  132.          Top             =   1800
  133.          Width           =   1335
  134.       End
  135.       Begin VB.Label StatsLbl 
  136.          BackStyle       =   0  'Transparent
  137.          BeginProperty Font 
  138.             Name            =   "Verdana"
  139.             Size            =   8.25
  140.             Charset         =   0
  141.             Weight          =   400
  142.             Underline       =   0   'False
  143.             Italic          =   0   'False
  144.             Strikethrough   =   0   'False
  145.          EndProperty
  146.          Height          =   255
  147.          Index           =   0
  148.          Left            =   2520
  149.          TabIndex        =   16
  150.          Top             =   360
  151.          Width           =   3495
  152.       End
  153.       Begin VB.Label StatsLbl 
  154.          BackStyle       =   0  'Transparent
  155.          BeginProperty Font 
  156.             Name            =   "Verdana"
  157.             Size            =   8.25
  158.             Charset         =   0
  159.             Weight          =   400
  160.             Underline       =   0   'False
  161.             Italic          =   0   'False
  162.             Strikethrough   =   0   'False
  163.          EndProperty
  164.          Height          =   255
  165.          Index           =   1
  166.          Left            =   2520
  167.          TabIndex        =   15
  168.          Top             =   840
  169.          Width           =   3495
  170.       End
  171.       Begin VB.Label StatsLbl 
  172.          BackStyle       =   0  'Transparent
  173.          BeginProperty Font 
  174.             Name            =   "Verdana"
  175.             Size            =   8.25
  176.             Charset         =   0
  177.             Weight          =   400
  178.             Underline       =   0   'False
  179.             Italic          =   0   'False
  180.             Strikethrough   =   0   'False
  181.          EndProperty
  182.          Height          =   255
  183.          Index           =   2
  184.          Left            =   2520
  185.          TabIndex        =   14
  186.          Top             =   1320
  187.          Width           =   3495
  188.       End
  189.       Begin VB.Label StatsLbl 
  190.          BackStyle       =   0  'Transparent
  191.          BeginProperty Font 
  192.             Name            =   "Verdana"
  193.             Size            =   8.25
  194.             Charset         =   0
  195.             Weight          =   400
  196.             Underline       =   0   'False
  197.             Italic          =   0   'False
  198.             Strikethrough   =   0   'False
  199.          EndProperty
  200.          Height          =   255
  201.          Index           =   3
  202.          Left            =   2520
  203.          TabIndex        =   13
  204.          Top             =   1800
  205.          Width           =   3495
  206.       End
  207.    End
  208.    Begin VB.CommandButton DecryptFile 
  209.       Caption         =   "Decrypt File"
  210.       BeginProperty Font 
  211.          Name            =   "Verdana"
  212.          Size            =   8.25
  213.          Charset         =   0
  214.          Weight          =   400
  215.          Underline       =   0   'False
  216.          Italic          =   0   'False
  217.          Strikethrough   =   0   'False
  218.       EndProperty
  219.       Height          =   375
  220.       Left            =   4560
  221.       TabIndex        =   11
  222.       Top             =   1920
  223.       Width           =   1575
  224.    End
  225.    Begin VB.CommandButton EncryptFile 
  226.       Caption         =   "Encrypt File"
  227.       BeginProperty Font 
  228.          Name            =   "Verdana"
  229.          Size            =   8.25
  230.          Charset         =   0
  231.          Weight          =   400
  232.          Underline       =   0   'False
  233.          Italic          =   0   'False
  234.          Strikethrough   =   0   'False
  235.       EndProperty
  236.       Height          =   375
  237.       Left            =   2880
  238.       TabIndex        =   10
  239.       Top             =   1920
  240.       Width           =   1575
  241.    End
  242.    Begin VB.CommandButton SwapCmd 
  243.       Caption         =   "Send in Encrypt TextBox"
  244.       BeginProperty Font 
  245.          Name            =   "Verdana"
  246.          Size            =   8.25
  247.          Charset         =   0
  248.          Weight          =   400
  249.          Underline       =   0   'False
  250.          Italic          =   0   'False
  251.          Strikethrough   =   0   'False
  252.       EndProperty
  253.       Height          =   375
  254.       Left            =   240
  255.       TabIndex        =   8
  256.       Top             =   7320
  257.       Width           =   2295
  258.    End
  259.    Begin VB.CommandButton Decrypt 
  260.       Caption         =   "Decrypt"
  261.       BeginProperty Font 
  262.          Name            =   "Verdana"
  263.          Size            =   8.25
  264.          Charset         =   0
  265.          Weight          =   400
  266.          Underline       =   0   'False
  267.          Italic          =   0   'False
  268.          Strikethrough   =   0   'False
  269.       EndProperty
  270.       Height          =   375
  271.       Left            =   1440
  272.       TabIndex        =   4
  273.       Top             =   1920
  274.       Width           =   1335
  275.    End
  276.    Begin RichTextLib.RichTextBox t2 
  277.       Height          =   2175
  278.       Left            =   120
  279.       TabIndex        =   2
  280.       Top             =   4920
  281.       Width           =   6015
  282.       _ExtentX        =   10610
  283.       _ExtentY        =   3836
  284.       _Version        =   393217
  285.       Enabled         =   -1  'True
  286.       ScrollBars      =   3
  287.       TextRTF         =   $"MainFrm.frx":7EFB
  288.    End
  289.    Begin RichTextLib.RichTextBox t1 
  290.       Height          =   1695
  291.       Left            =   120
  292.       TabIndex        =   1
  293.       Top             =   0
  294.       Width           =   6015
  295.       _ExtentX        =   10610
  296.       _ExtentY        =   2990
  297.       _Version        =   393217
  298.       Enabled         =   -1  'True
  299.       ScrollBars      =   3
  300.       TextRTF         =   $"MainFrm.frx":7F7D
  301.    End
  302.    Begin VB.CommandButton Encrypt 
  303.       Caption         =   "Encrypt"
  304.       BeginProperty Font 
  305.          Name            =   "Verdana"
  306.          Size            =   8.25
  307.          Charset         =   0
  308.          Weight          =   400
  309.          Underline       =   0   'False
  310.          Italic          =   0   'False
  311.          Strikethrough   =   0   'False
  312.       EndProperty
  313.       Height          =   375
  314.       Left            =   120
  315.       TabIndex        =   0
  316.       Top             =   1920
  317.       Width           =   1215
  318.    End
  319.    Begin VB.Label Label11 
  320.       Caption         =   "Character Lenght :"
  321.       BeginProperty Font 
  322.          Name            =   "Verdana"
  323.          Size            =   8.25
  324.          Charset         =   0
  325.          Weight          =   400
  326.          Underline       =   0   'False
  327.          Italic          =   0   'False
  328.          Strikethrough   =   0   'False
  329.       EndProperty
  330.       Height          =   255
  331.       Index           =   1
  332.       Left            =   240
  333.       TabIndex        =   24
  334.       Top             =   7080
  335.       Width           =   1695
  336.    End
  337.    Begin VB.Label ResLenLbl 
  338.       BeginProperty Font 
  339.          Name            =   "Verdana"
  340.          Size            =   8.25
  341.          Charset         =   0
  342.          Weight          =   400
  343.          Underline       =   0   'False
  344.          Italic          =   0   'False
  345.          Strikethrough   =   0   'False
  346.       EndProperty
  347.       Height          =   255
  348.       Left            =   1920
  349.       TabIndex        =   23
  350.       Top             =   7080
  351.       Width           =   4095
  352.    End
  353.    Begin VB.Label ChrLenLbl 
  354.       BeginProperty Font 
  355.          Name            =   "Verdana"
  356.          Size            =   8.25
  357.          Charset         =   0
  358.          Weight          =   400
  359.          Underline       =   0   'False
  360.          Italic          =   0   'False
  361.          Strikethrough   =   0   'False
  362.       EndProperty
  363.       Height          =   255
  364.       Left            =   1800
  365.       TabIndex        =   22
  366.       Top             =   1680
  367.       Width           =   4095
  368.    End
  369.    Begin VB.Label Label11 
  370.       Caption         =   "Character Lenght :"
  371.       BeginProperty Font 
  372.          Name            =   "Verdana"
  373.          Size            =   8.25
  374.          Charset         =   0
  375.          Weight          =   400
  376.          Underline       =   0   'False
  377.          Italic          =   0   'False
  378.          Strikethrough   =   0   'False
  379.       EndProperty
  380.       Height          =   255
  381.       Index           =   0
  382.       Left            =   120
  383.       TabIndex        =   21
  384.       Top             =   1680
  385.       Width           =   1695
  386.    End
  387.    Begin VB.Label Label6 
  388.       Caption         =   "*there is some Chr you cant copy paste"
  389.       BeginProperty Font 
  390.          Name            =   "Verdana"
  391.          Size            =   8.25
  392.          Charset         =   0
  393.          Weight          =   400
  394.          Underline       =   0   'False
  395.          Italic          =   0   'False
  396.          Strikethrough   =   0   'False
  397.       EndProperty
  398.       Height          =   255
  399.       Left            =   2640
  400.       TabIndex        =   9
  401.       Top             =   7440
  402.       Width           =   3495
  403.    End
  404.    Begin VB.Label Label5 
  405.       Caption         =   "Result (Will save to a file if Encrypt File is used) :"
  406.       BeginProperty Font 
  407.          Name            =   "Verdana"
  408.          Size            =   8.25
  409.          Charset         =   0
  410.          Weight          =   400
  411.          Underline       =   0   'False
  412.          Italic          =   0   'False
  413.          Strikethrough   =   0   'False
  414.       EndProperty
  415.       Height          =   255
  416.       Left            =   120
  417.       TabIndex        =   3
  418.       Top             =   4680
  419.       Width           =   6015
  420.    End
  421.    Begin VB.Menu SettingCmd 
  422.       Caption         =   "Setting"
  423.    End
  424. End
  425. Attribute VB_Name = "MainFrm"
  426. Attribute VB_GlobalNameSpace = False
  427. Attribute VB_Creatable = False
  428. Attribute VB_PredeclaredId = True
  429. Attribute VB_Exposed = False
  430. Option Explicit
  431.  
  432. 'Let me explain what the graph does!
  433. 'This is the base algorithm where X value is the position in the string to encrypt
  434. 'This 100% came out of my mind and i personnaly never saw any encryption using this method
  435. 'If you know whats a Sin() and how it look in a graph you can read the rest
  436. 'decal is the X interval between each time Y hit 0 or whatever is your range and start value
  437. '*Note Higher decal = more chance of character repetition
  438. 'Start is the Y starting position
  439. 'Range is the Minimum and maximum Y can reach ex: Start - Range is minimum and Start + Range is maximum
  440. 'Dont use higher range than start position and dont make it get past 256
  441. 'USING A 0 RANGE DOES NOT MEAN THE ENCRYPTED VERSION WILL BE 1 KIND OF CHR
  442. 'IN THE ENCRYPTION THE Y VALUE IS MODIFIED
  443.  
  444.  
  445.  
  446. Private Sub DecryptFile_Click()
  447. Encrypt.Enabled = False 'Make button impossible to use
  448. Decrypt.Enabled = False 'Make button impossible to use
  449. EncryptFile.Enabled = False 'Make button impossible to use
  450. DecryptFile.Enabled = False 'Make button impossible to use
  451. DoEvents
  452.     'Master variables initializing
  453.     Dim Path As String 'Var holding path of file to encrypt or decrypt
  454.     Dim SavePath As String 'Var holding the save path
  455.     Dim st As Long 'Var holding value of GetTickCount when action start (Statistics)
  456.     Dim Crypt() As Byte 'Variable getting file data (This var get resized and get different size of the file for optimization)
  457.     Dim Res() As Byte 'This is same as Crypt() but its the datas once encrypted (Array is gonna be EXACT SAME SIZE)
  458.     'Show Unused in stats frame
  459.     StatsLbl(0).Caption = "Unused" 'Show that those kind of stats arent used with files
  460.     StatsLbl(1).Caption = "Unused" 'Show that those kind of stats arent used with files
  461.     StatsLbl(2).Caption = "Unused" 'Show that those kind of stats arent used with files
  462.     StatsLbl(3).Caption = "Unused" 'Show that those kind of stats arent used with files
  463.     '###Get file to encrypt###
  464.     Dlg.DialogTitle = "Select File to Encrypt/Decrypt"
  465.     Dlg.ShowOpen
  466.     Path = Dlg.Filename
  467.     '#########################
  468.     '####Get path to save#####
  469.     Dlg.DialogTitle = "Enter path to save file"
  470.     Dlg.ShowOpen
  471.     SavePath = Dlg.Filename
  472.     '#########################
  473.     If Not SavePath = "" And Not Path = "" Then
  474.     
  475.         Dim xVal() As Byte 'Buffer variable
  476.         Dim segment As Double 'Number of segment Fix(Size / buffer) + 1
  477.         Dim FileL As Double 'Length of the file
  478.         FileL = LengthOfFile(Path) 'Set length of file
  479.         segment = Fix(FileL / Chunk) + 1 'Set Number of segment
  480.         Dim i As Double 'Variable used to loop (also the position in the segment)
  481.         st = GetTickCount ' sT is the starting gettickcount value . Used for statistics
  482.         Dim Freenum As Integer 'File number of the file to encrypt/decrypt
  483.         Freenum = FreeFile 'Initialize file number
  484.         Dim Freenum2 As Integer 'File number of the path to save
  485.         Dim Str As String
  486.         Open Path For Binary Access Read As #Freenum 'Open the first path before giving file number to save path (otherwise you will get same value for both)
  487.         Freenum2 = FreeFile 'Now you can give him a number
  488.         Open SavePath For Binary Access Write As #Freenum2 'Initialize the save path
  489.         For i = 1 To segment 'Loop in the file buffers (Segment)
  490.             Dim PercentX As Double 'Variable holding percent value (Statistics)
  491.             Dim TimeRemain As Double 'Variable holding time remaining (Statistics)
  492.             Dim FilePos As Double 'Variable holding the file position NOT IN SEGMENT, IN CHARACTER LENGTH VALUE
  493.             Dim Speed As String 'Variable holding the speed per second in Mb (Statistics)
  494.             TimeRemain = GetTimeRemaining(FileL, Chunk, st, i) 'Get time remaining value (Statistics)
  495.             PercentX = GetPercent(i, segment) 'Get percent value (Statistics)
  496.             Speed = GetSpeed(st, Chunk, i)
  497.             FilePos = i * Chunk 'Number of segment * Characters in a segment
  498.             If i * Chunk > FileL Then
  499.                 FilePos = FileL ' Just so it cant go over the file length
  500.             End If
  501.             'This line just show stats in the form caption
  502.             MainFrm.Caption = "SINE256 Visualisation And Sample Console... Decrypting Segment (" & i & "/" & segment & ") (" & FilePos & "/" & FileL & ") (" & PercentX & "%) Time Remaining : " & TimeRemain & "s (Speed : " & Speed & "/s)"
  503.             Dim Bnd As Double 'Buffer calculation (Make sure it doesnt use the full buffer on the last segment which is very rare is the same size as the others)
  504.             If i = segment Then
  505.                 Bnd = FileL - (Chunk * (i - 1)) 'Its the last segment so let calculate its real size
  506.             Else
  507.                 Bnd = Chunk 'Full buffer
  508.             End If
  509.             ReDim xVal(0 To (Bnd - 1)) 'Resize the Byte array variable
  510.             DoEvents
  511.             If Not EOF(Freenum) Then 'If end of file isnt reached(in case of very exceptionnal error)
  512.                 Get #Freenum, , xVal() 'Get data from file with the byte array size which is Bnd
  513.                 DoEvents
  514.                 cl.SINE256Decrypt xVal(), Res(), password, PatternLen 'Encrypt/Decrypt the current Segment
  515.                 DoEvents
  516.                 Put #Freenum2, , Res() 'Save Result to the save path
  517.                 DoEvents
  518.             End If
  519.         Next ' Loop through i
  520.  
  521.         Close #Freenum 'Close file (It is now usable)
  522.         Close #Freenum2 'Close file (It is now usable)
  523.  
  524.          MsgBox "Finished! File length was " & FileL & " characters. Encrypted/Decrypted at " & Round((1000 / (GetTickCount - st)) * FileL) & "Chrs per second", vbInformation
  525.  
  526.     End If
  527. xStop:
  528. Encrypt.Enabled = True 'Make button possible to use
  529. Decrypt.Enabled = True 'Make button possible to use
  530. EncryptFile.Enabled = True 'Make button possible to use
  531. DecryptFile.Enabled = True 'Make button possible to use
  532. End Sub
  533.  
  534. Private Sub EncryptFile_Click()
  535. Encrypt.Enabled = False 'Make button impossible to use
  536. Decrypt.Enabled = False 'Make button impossible to use
  537. EncryptFile.Enabled = False 'Make button impossible to use
  538. DecryptFile.Enabled = False 'Make button impossible to use
  539. DoEvents
  540.     'Master variables initializing
  541.     Dim Path As String 'Var holding path of file to encrypt or decrypt
  542.     Dim SavePath As String 'Var holding the save path
  543.     Dim st As Long 'Var holding value of GetTickCount when action start (Statistics)
  544.     Dim Crypt() As Byte 'Variable getting file data (This var get resized and get different size of the file for optimization)
  545.     Dim Res() As Byte 'This is same as Crypt() but its the datas once encrypted (Array is gonna be EXACT SAME SIZE)
  546.     'Show Unused in stats frame
  547.     StatsLbl(0).Caption = "Unused" 'Show that those kind of stats arent used with files
  548.     StatsLbl(1).Caption = "Unused" 'Show that those kind of stats arent used with files
  549.     StatsLbl(2).Caption = "Unused" 'Show that those kind of stats arent used with files
  550.     StatsLbl(3).Caption = "Unused" 'Show that those kind of stats arent used with files
  551.     '###Get file to encrypt###
  552.     Dlg.DialogTitle = "Select File to Encrypt/Decrypt"
  553.     Dlg.ShowOpen
  554.     Path = Dlg.Filename
  555.     '#########################
  556.     '####Get path to save#####
  557.     Dlg.DialogTitle = "Enter path to save file"
  558.     Dlg.ShowOpen
  559.     SavePath = Dlg.Filename
  560.     '#########################
  561.     If Not SavePath = "" And Not Path = "" Then
  562.     
  563.         Dim xVal() As Byte 'Buffer variable
  564.         Dim segment As Double 'Number of segment Fix(Size / buffer) + 1
  565.         Dim FileL As Double 'Length of the file
  566.         FileL = LengthOfFile(Path) 'Set length of file
  567.         segment = Fix(FileL / Chunk) + 1 'Set Number of segment
  568.         Dim i As Double 'Variable used to loop (also the position in the segment)
  569.         st = GetTickCount ' sT is the starting gettickcount value . Used for statistics
  570.         Dim Freenum As Integer 'File number of the file to encrypt/decrypt
  571.         Freenum = FreeFile 'Initialize file number
  572.         Dim Freenum2 As Integer 'File number of the path to save
  573.         Dim Str As String
  574.         Open Path For Binary Access Read As #Freenum 'Open the first path before giving file number to save path (otherwise you will get same value for both)
  575.         Freenum2 = FreeFile 'Now you can give him a number
  576.         Open SavePath For Binary Access Write As #Freenum2 'Initialize the save path
  577.         For i = 1 To segment 'Loop in the file buffers (Segment)
  578.             Dim PercentX As Double 'Variable holding percent value (Statistics)
  579.             Dim TimeRemain As Double 'Variable holding time remaining (Statistics)
  580.             Dim FilePos As Double 'Variable holding the file position NOT IN SEGMENT, IN CHARACTER LENGTH VALUE
  581.             Dim Speed As String 'Variable holding the speed per second in Mb (Statistics)
  582.             TimeRemain = GetTimeRemaining(FileL, Chunk, st, i) 'Get time remaining value (Statistics)
  583.             PercentX = GetPercent(i, segment) 'Get percent value (Statistics)
  584.             Speed = GetSpeed(st, Chunk, i)
  585.             FilePos = i * Chunk 'Number of segment * Characters in a segment
  586.             If i * Chunk > FileL Then
  587.                 FilePos = FileL ' Just so it cant go over the file length
  588.             End If
  589.             'This line just show stats in the form caption
  590.             MainFrm.Caption = "SINE256 Visualisation And Sample Console... Crypting Segment (" & i & "/" & segment & ") (" & FilePos & "/" & FileL & ") (" & PercentX & "%) Time Remaining : " & TimeRemain & "s (Speed : " & Speed & "/s)"
  591.             Dim Bnd As Double 'Buffer calculation (Make sure it doesnt use the full buffer on the last segment which is very rare is the same size as the others)
  592.             If i = segment Then
  593.                 Bnd = FileL - (Chunk * (i - 1)) 'Its the last segment so let calculate its real size
  594.             Else
  595.                 Bnd = Chunk 'Full buffer
  596.             End If
  597.             ReDim xVal(0 To (Bnd - 1)) 'Resize the Byte array variable
  598.             DoEvents
  599.             If Not EOF(Freenum) Then 'If end of file isnt reached(in case of very exceptionnal error)
  600.                 Get #Freenum, , xVal() 'Get data from file with the byte array size which is Bnd
  601.                 DoEvents
  602.                 cl.SINE256Encrypt xVal(), Res(), password, PatternLen 'Encrypt/Decrypt the current Segment
  603.                 DoEvents
  604.                 Put #Freenum2, , Res() 'Save Result to the save path
  605.                 DoEvents
  606.             End If
  607.         Next ' Loop through i
  608.  
  609.         Close #Freenum 'Close file (It is now usable)
  610.         Close #Freenum2 'Close file (It is now usable)
  611.  
  612.          MsgBox "Finished! File length was " & FileL & " characters. Encrypted/Decrypted at " & Round((1000 / (GetTickCount - st)) * FileL) & "Chrs per second", vbInformation
  613.  
  614.     End If
  615. xStop:
  616. Encrypt.Enabled = True 'Make button possible to use
  617. Decrypt.Enabled = True 'Make button possible to use
  618. EncryptFile.Enabled = True 'Make button possible to use
  619. DecryptFile.Enabled = True 'Make button possible to use
  620. End Sub
  621.  
  622. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  623.     Unload Me
  624. End Sub
  625.  
  626. Private Sub Form_Terminate()
  627.     Unload Me
  628. End Sub
  629.  
  630. Private Sub Form_Unload(Cancel As Integer)
  631.     End
  632. End Sub
  633.  
  634.  
  635.  
  636. 'If you wanna study this encryption ignore the module and everything in here but the encrypt and decrypt button
  637. Private Sub RefreshBaseGraph_Click()
  638.     Dim Xb() As Double
  639.     'This draw the algorithm in a graph (This is the base stuff, nothing is mixed yet)
  640.     Xb() = cl.MakeGraph(decal, start, rangE, PatternLen) 'Initialize the graphic in the class and in the graphic (NEED TO BE INITIALIZED AT LEAST ONCE FOR IT TO WORK)
  641.     ChartIt2 AlgoChart, Xb() 'Refresh the top graph
  642. End Sub
  643.  
  644. Private Sub SettingCmd_Click()
  645.     SettingFrm.Show
  646.     SettingFrm.SetFocus
  647. End Sub
  648.  
  649. Private Sub SwapCmd_Click()
  650.     t1.Text = t2.Text 'Simply move text to another text box
  651.     t2.Text = ""
  652. End Sub
  653.  
  654.  
  655. Private Sub Decrypt_Click() 'No need to explain , its same as encrypt sub but with the decrypt function
  656. Encrypt.Enabled = False
  657. Decrypt.Enabled = False
  658. EncryptFile.Enabled = False
  659. DecryptFile.Enabled = False
  660. DoEvents
  661. Dim st As Long
  662. If Not t1.Text = "" Then
  663.     Dim Dcrypt() As Byte
  664.     Dim Res() As Byte
  665.     st = GetTickCount
  666.     Dcrypt() = StrConv(t1.Text, vbFromUnicode)
  667.     StatsLbl(0).Caption = GetTickCount - st & "ms"
  668.     st = GetTickCount
  669.     cl.SINE256Decrypt Dcrypt(), Res(), password, PatternLen
  670.     StatsLbl(1).Caption = GetTickCount - st & "ms"
  671.     Dim R As String
  672.     st = GetTickCount
  673.     R = StrConv(Res, vbUnicode)
  674.     StatsLbl(2).Caption = GetTickCount - st & "ms"
  675.     st = GetTickCount
  676.     t2.Text = R
  677.     t1.Text = ""
  678.     StatsLbl(3).Caption = GetTickCount - st & "ms"
  679. End If
  680. Encrypt.Enabled = True
  681. Decrypt.Enabled = True
  682. EncryptFile.Enabled = True
  683. DecryptFile.Enabled = True
  684. End Sub
  685.  
  686. Private Sub Encrypt_Click()
  687. Encrypt.Enabled = False
  688. Decrypt.Enabled = False
  689. EncryptFile.Enabled = False
  690. DecryptFile.Enabled = False
  691. DoEvents
  692. Dim st As Long
  693. If Not t1.Text = "" Then
  694.     Dim Graph As Boolean
  695.     Select Case MsgBox("Do you want to draw the datas in the graph ? Careful, very long strings can freeze the program. Only use for string under 5000 character for safety.", vbYesNo)
  696.     Case 6 'He clicked YES
  697.         Graph = True
  698.     Case 7 'He clicked No
  699.         Graph = False
  700.     End Select
  701.     Dim Crypt() As Byte 'Variable holding datas to encrypt (need to be in bytes)
  702.     Dim Res() As Byte 'Variable holding the encrypted Data (need to be in bytes)
  703.     st = GetTickCount
  704.     Crypt = StrConv(t1.Text, vbFromUnicode) 'Convert the text in the text box into Bytes array (Its fast!)
  705.     StatsLbl(0).Caption = GetTickCount - st & "ms"
  706.     st = GetTickCount
  707.     cl.SINE256Encrypt Crypt(), Res(), password, PatternLen 'Let's my module convert the stuff
  708.     StatsLbl(1).Caption = GetTickCount - st & "ms"
  709.     st = GetTickCount
  710.     Dim Dat As String
  711.     Dat = StrConv(Res, vbUnicode)
  712.     StatsLbl(2).Caption = GetTickCount - st & "ms"
  713.     st = GetTickCount
  714.     DoEvents
  715.     If Graph = True Then
  716.         ChartIt TextChart, Crypt 'Draw the stuff in the graph
  717.         ChartIt CryptChart, Res 'Draw the stuff in the graph
  718.     End If
  719.     t2.Text = Dat 'Show string
  720.     t1.Text = ""
  721.     StatsLbl(3).Caption = GetTickCount - st & "ms"
  722. End If
  723. Encrypt.Enabled = True
  724. Decrypt.Enabled = True
  725. EncryptFile.Enabled = True
  726. DecryptFile.Enabled = True
  727. End Sub
  728.  
  729.  
  730.  
  731.  
  732. Private Sub Form_Load()
  733.  
  734.     Dim z(0 To 1) As Long 'Used to clear the graph with the annoying starting datas
  735.     AlgoChart.ChartData = z 'Clear graph3
  736.     TextChart.ChartData = z 'Clear graph2
  737.     CryptChart.ChartData = z 'Clear graph1
  738.     PatternLen = 50000 'Give patternLen as starting value
  739.     decal = 1 'Give the decal a starting value
  740.     start = 128 'Give the start a starting value
  741.     rangE = 128 'Give the range a starting value
  742.     Chunk = 1048576 'Give buffer size a starting value
  743.         
  744.         ChartIt2 AlgoChart, cl.MakeGraph(decal, start, rangE, PatternLen)
  745. End Sub
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754. Private Sub t1_Change()
  755.     ChrLenLbl.Caption = Len(t1.Text)
  756. End Sub
  757.  
  758. Private Sub t2_Change()
  759.     ResLenLbl.Caption = Len(t2.Text)
  760. End Sub
  761.