SlideShare a Scribd company logo
1 of 5
Ketikkan Coding :
Imports Encryption.Crypto.Secret
Public Class Form1
'Reflects the index of the image
Private Enum Images
Encrypted = 0
Decrypted = 1
Folder_Open = 2
End Enum
#Region " Events"
#Region " Form Events"
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.btnEncrypt.Image = Me.ImageList1.Images(Images.Encrypted)
Me.btnDecrypt.Image = Me.ImageList1.Images(Images.Decrypted)
Me.btnOpenInput.Image = Me.ImageList1.Images(Images.Folder_Open)
Me.btnOpenOutput.Image = Me.ImageList1.Images(Images.Folder_Open)
End Sub
#End Region

'Form Events

#Region " Control Events"
Private Sub Open(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles btnOpenInput.Click
Dim btn As Button = DirectCast(sender, Button)
'The name of the TextBox to return the selected file path to is stored
' in the Tag property of the button.
Dim tb As TextBox = _
DirectCast(btn.Parent.Controls(btn.Tag.ToString()), TextBox)
Dim diag As New OpenFileDialog()
With diag
.CheckFileExists = True
.CheckPathExists = True
.Multiselect = False
.RestoreDirectory = True
.Title = "Please select an Input file"
.Filter = "All Files (*.*)|*.*"
.ShowDialog()
'Set the file path if one was selected
If .FileName.Trim() <> "" Then _
tb.Text = .FileName
End With
diag.Dispose()
End Sub

Private Sub Save(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnOpenOutput.Click
Dim btn As Button = DirectCast(sender, Button)
'The name of the TextBox to return the selected file path to is stored
' in the Tag property of the button.
Dim tb As TextBox = _
DirectCast(btn.Parent.Controls(btn.Tag.ToString()), TextBox)
Dim diag As New SaveFileDialog()
With diag
.AddExtension = True
.CheckFileExists = False
.CheckPathExists = True
.CreatePrompt = False
'Set the extension if there is an input file
If My.Computer.FileSystem.FileExists(Me.tbInput.Text.Trim()) = True Then
.DefaultExt = System.IO.Path.GetExtension(Me.tbInput.Text)
'Set the filter to whatever type of file was selected as an input file
.Filter = String.Concat(StrConv(.DefaultExt, VbStrConv.ProperCase), _
" Files (*.", .DefaultExt, ")|*.", .DefaultExt, _
"|All Files (*.*)|*.*")
Else
.Filter &= "All Files (*.*)|*.*"
End If
.OverwritePrompt = True
.RestoreDirectory = True
.Title = "Please enter an output file."
.ShowDialog()
If .FileName.Trim() <> "" Then _
tb.Text = .FileName
End With
diag.Dispose()
End Sub

Private Sub btnEncrypt_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnEncrypt.Click
'Get the reference to the button that was clicked
Dim clickedButton As Button = DirectCast(sender, Button)
'Call the EncryptDecrypt method and pass to it the Button that was clicked
EncryptDecrypt(clickedButton)
MessageBox.Show("Encryption complete!", "Encryption complete", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

Private Sub btnDecrypt_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnDecrypt.Click
'Get the reference to the button that was clicked
Dim clickedButton As Button = DirectCast(sender, Button)
'Call the EncryptDecrypt method and pass to it the Button that was clicked
EncryptDecrypt(clickedButton)
MessageBox.Show("Decryption complete!", "Decryption complete", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

Private Sub lblWikiLink_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles lblWikiLink.Click
System.Diagnostics.Process.Start(Me.lblWikiLink.Text)
End Sub

Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles
rbAes.CheckedChanged, rbTripleDes.CheckedChanged, rbRijndael.CheckedChanged,
rbRc2.CheckedChanged, rbDes.CheckedChanged
Dim enc As Encryption.Crypto.Secret._BaseEncryption = _
GetEncryptor()

tbSecretEncryptorDesc.Text = enc.Description
End Sub
#End Region

'Control Events

#End Region

'Events

#Region " Methods"
Private Sub EncryptDecrypt(ByVal clickedButton As Button)
'Create a new instance of the _BaseEncryption class,
' and get the appropriate encryptor class
Dim enc As Encryption.Crypto.Secret._BaseEncryption = _
GetEncryptor()
'Encrypt or Decrypt the selected file.
' (This will call the corresponding method in the actual class)
If clickedButton.Text = "Encrypt" Then
enc.Encrypt(Me.tbInput.Text.Trim(), Me.tbOutput.Text.Trim())
ElseIf clickedButton.Text = "Decrypt" Then
enc.Decrypt(Me.tbInput.Text.Trim(), Me.tbOutput.Text.Trim())
End If
End Sub

Private Function GetEncryptor() As _BaseEncryption
Dim enc As Encryption.Crypto.Secret._BaseEncryption = Nothing
Dim wikiLink As String = String.Empty
'Set the _BaseEncryption class to the class corresponding to the RadioButton
' that was clicked
Select Case True
Case Me.rbAes.Checked
enc = AES.Create()
wikiLink = "http://en.wikipedia.org/wiki/Advanced_Encryption_Standard"
Case Me.rbDes.Checked
enc = DES.Create()
wikiLink = "http://en.wikipedia.org/wiki/Data_Encryption_Standard"
Case Me.rbRc2.Checked
enc = Rc2.Create()
wikiLink = "http://en.wikipedia.org/wiki/RC2"
Case Me.rbRijndael.Checked
enc = Rijndael.Create()
wikiLink = "http://en.wikipedia.org/wiki/Rijndael_encryption_algorithm"
Case Me.rbTripleDes.Checked
enc = TripleDes.Create()
wikiLink = "http://en.wikipedia.org/wiki/Triple_DES"
End Select
Me.lblWikiLink.Text = wikiLink
Return enc
End Function
#End Region
End Class

'Methods

More Related Content

What's hot

Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5sotlsoc
 
Código Opção Substituir
Código Opção SubstituirCódigo Opção Substituir
Código Opção Substituircymbron
 
Código Editor Net
Código Editor NetCódigo Editor Net
Código Editor Netcymbron
 
Creating Ext GWT Extensions and Components
Creating Ext GWT Extensions and ComponentsCreating Ext GWT Extensions and Components
Creating Ext GWT Extensions and ComponentsSencha
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandlingArati Gadgil
 
Código Acerca Editor_Net
Código Acerca Editor_NetCódigo Acerca Editor_Net
Código Acerca Editor_Netcymbron
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART IIIOXUS 20
 
Lesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFLesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFQuang Nguyễn Bá
 
Código fuente del software educativo
Código fuente del software educativoCódigo fuente del software educativo
Código fuente del software educativoLeo Chavez Martinez
 
Ordenar vector
Ordenar vectorOrdenar vector
Ordenar vectorecasteloc
 
Código fuente del software educativo
Código fuente del software educativoCódigo fuente del software educativo
Código fuente del software educativoLeo Chavez Martinez
 

What's hot (18)

Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
 
Trabajo de case
Trabajo de caseTrabajo de case
Trabajo de case
 
Código Opção Substituir
Código Opção SubstituirCódigo Opção Substituir
Código Opção Substituir
 
Código Editor Net
Código Editor NetCódigo Editor Net
Código Editor Net
 
Creating Ext GWT Extensions and Components
Creating Ext GWT Extensions and ComponentsCreating Ext GWT Extensions and Components
Creating Ext GWT Extensions and Components
 
Event handling in Java(part 2)
Event handling in Java(part 2)Event handling in Java(part 2)
Event handling in Java(part 2)
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandling
 
Trabajo de case
Trabajo de caseTrabajo de case
Trabajo de case
 
Código Acerca Editor_Net
Código Acerca Editor_NetCódigo Acerca Editor_Net
Código Acerca Editor_Net
 
Stop watch and array
Stop watch and arrayStop watch and array
Stop watch and array
 
Work flow
Work flowWork flow
Work flow
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART III
 
Event handling in Java(part 1)
Event handling in Java(part 1)Event handling in Java(part 1)
Event handling in Java(part 1)
 
Lesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFLesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPF
 
Código fuente del software educativo
Código fuente del software educativoCódigo fuente del software educativo
Código fuente del software educativo
 
Ordenar vector
Ordenar vectorOrdenar vector
Ordenar vector
 
CRUD VB2010
CRUD VB2010CRUD VB2010
CRUD VB2010
 
Código fuente del software educativo
Código fuente del software educativoCódigo fuente del software educativo
Código fuente del software educativo
 

Similar to Metode

Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdf
  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdfapnashop1
 
Elementos del lenguaje
Elementos del lenguajeElementos del lenguaje
Elementos del lenguajeguest6473b8
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docxcorbing9ttj
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docxcorbing9ttj
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventasDAYANA RETO
 
Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01mafv1976
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITYDOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITYGOKUL SREE
 
Ensayo Convergencia Informatica
Ensayo Convergencia InformaticaEnsayo Convergencia Informatica
Ensayo Convergencia Informaticamiguel camelo
 
C++ Windows Forms L10 - Instantiate
C++ Windows Forms L10 - InstantiateC++ Windows Forms L10 - Instantiate
C++ Windows Forms L10 - InstantiateMohammad Shaker
 
Inventory management
Inventory managementInventory management
Inventory managementRajeev Sharan
 
Event Handling in JAVA
Event Handling in JAVAEvent Handling in JAVA
Event Handling in JAVASrajan Shukla
 
Código fuente del software educativo
Código fuente del software educativoCódigo fuente del software educativo
Código fuente del software educativoLeo Chavez Martinez
 
Puerto serialarduino
Puerto serialarduinoPuerto serialarduino
Puerto serialarduinozadkiel_123
 

Similar to Metode (20)

Docimp
DocimpDocimp
Docimp
 
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdf
  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdf
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
 
Elementos del lenguaje
Elementos del lenguajeElementos del lenguaje
Elementos del lenguaje
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventas
 
Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01
 
Colegio municipal
Colegio municipalColegio municipal
Colegio municipal
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITYDOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
Ensayo Convergencia Informatica
Ensayo Convergencia InformaticaEnsayo Convergencia Informatica
Ensayo Convergencia Informatica
 
Ete programs
Ete programsEte programs
Ete programs
 
Calculator code
Calculator codeCalculator code
Calculator code
 
C++ Windows Forms L10 - Instantiate
C++ Windows Forms L10 - InstantiateC++ Windows Forms L10 - Instantiate
C++ Windows Forms L10 - Instantiate
 
Inventory management
Inventory managementInventory management
Inventory management
 
Event Handling in JAVA
Event Handling in JAVAEvent Handling in JAVA
Event Handling in JAVA
 
Código fuente del software educativo
Código fuente del software educativoCódigo fuente del software educativo
Código fuente del software educativo
 
Androd Listeners
Androd ListenersAndrod Listeners
Androd Listeners
 
Puerto serialarduino
Puerto serialarduinoPuerto serialarduino
Puerto serialarduino
 

Recently uploaded

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 

Recently uploaded (20)

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

Metode

  • 1. Ketikkan Coding : Imports Encryption.Crypto.Secret Public Class Form1 'Reflects the index of the image Private Enum Images Encrypted = 0 Decrypted = 1 Folder_Open = 2 End Enum
  • 2. #Region " Events" #Region " Form Events" Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Me.btnEncrypt.Image = Me.ImageList1.Images(Images.Encrypted) Me.btnDecrypt.Image = Me.ImageList1.Images(Images.Decrypted) Me.btnOpenInput.Image = Me.ImageList1.Images(Images.Folder_Open) Me.btnOpenOutput.Image = Me.ImageList1.Images(Images.Folder_Open) End Sub #End Region 'Form Events #Region " Control Events" Private Sub Open(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles btnOpenInput.Click Dim btn As Button = DirectCast(sender, Button) 'The name of the TextBox to return the selected file path to is stored ' in the Tag property of the button. Dim tb As TextBox = _ DirectCast(btn.Parent.Controls(btn.Tag.ToString()), TextBox) Dim diag As New OpenFileDialog() With diag .CheckFileExists = True .CheckPathExists = True .Multiselect = False .RestoreDirectory = True .Title = "Please select an Input file" .Filter = "All Files (*.*)|*.*" .ShowDialog() 'Set the file path if one was selected If .FileName.Trim() <> "" Then _ tb.Text = .FileName End With diag.Dispose() End Sub Private Sub Save(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnOpenOutput.Click Dim btn As Button = DirectCast(sender, Button) 'The name of the TextBox to return the selected file path to is stored ' in the Tag property of the button.
  • 3. Dim tb As TextBox = _ DirectCast(btn.Parent.Controls(btn.Tag.ToString()), TextBox) Dim diag As New SaveFileDialog() With diag .AddExtension = True .CheckFileExists = False .CheckPathExists = True .CreatePrompt = False 'Set the extension if there is an input file If My.Computer.FileSystem.FileExists(Me.tbInput.Text.Trim()) = True Then .DefaultExt = System.IO.Path.GetExtension(Me.tbInput.Text) 'Set the filter to whatever type of file was selected as an input file .Filter = String.Concat(StrConv(.DefaultExt, VbStrConv.ProperCase), _ " Files (*.", .DefaultExt, ")|*.", .DefaultExt, _ "|All Files (*.*)|*.*") Else .Filter &= "All Files (*.*)|*.*" End If .OverwritePrompt = True .RestoreDirectory = True .Title = "Please enter an output file." .ShowDialog() If .FileName.Trim() <> "" Then _ tb.Text = .FileName End With diag.Dispose() End Sub Private Sub btnEncrypt_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnEncrypt.Click 'Get the reference to the button that was clicked Dim clickedButton As Button = DirectCast(sender, Button) 'Call the EncryptDecrypt method and pass to it the Button that was clicked EncryptDecrypt(clickedButton) MessageBox.Show("Encryption complete!", "Encryption complete", _ MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub Private Sub btnDecrypt_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnDecrypt.Click 'Get the reference to the button that was clicked
  • 4. Dim clickedButton As Button = DirectCast(sender, Button) 'Call the EncryptDecrypt method and pass to it the Button that was clicked EncryptDecrypt(clickedButton) MessageBox.Show("Decryption complete!", "Decryption complete", _ MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub Private Sub lblWikiLink_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles lblWikiLink.Click System.Diagnostics.Process.Start(Me.lblWikiLink.Text) End Sub Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles rbAes.CheckedChanged, rbTripleDes.CheckedChanged, rbRijndael.CheckedChanged, rbRc2.CheckedChanged, rbDes.CheckedChanged Dim enc As Encryption.Crypto.Secret._BaseEncryption = _ GetEncryptor() tbSecretEncryptorDesc.Text = enc.Description End Sub #End Region 'Control Events #End Region 'Events #Region " Methods" Private Sub EncryptDecrypt(ByVal clickedButton As Button) 'Create a new instance of the _BaseEncryption class, ' and get the appropriate encryptor class Dim enc As Encryption.Crypto.Secret._BaseEncryption = _ GetEncryptor() 'Encrypt or Decrypt the selected file. ' (This will call the corresponding method in the actual class) If clickedButton.Text = "Encrypt" Then enc.Encrypt(Me.tbInput.Text.Trim(), Me.tbOutput.Text.Trim()) ElseIf clickedButton.Text = "Decrypt" Then enc.Decrypt(Me.tbInput.Text.Trim(), Me.tbOutput.Text.Trim()) End If
  • 5. End Sub Private Function GetEncryptor() As _BaseEncryption Dim enc As Encryption.Crypto.Secret._BaseEncryption = Nothing Dim wikiLink As String = String.Empty 'Set the _BaseEncryption class to the class corresponding to the RadioButton ' that was clicked Select Case True Case Me.rbAes.Checked enc = AES.Create() wikiLink = "http://en.wikipedia.org/wiki/Advanced_Encryption_Standard" Case Me.rbDes.Checked enc = DES.Create() wikiLink = "http://en.wikipedia.org/wiki/Data_Encryption_Standard" Case Me.rbRc2.Checked enc = Rc2.Create() wikiLink = "http://en.wikipedia.org/wiki/RC2" Case Me.rbRijndael.Checked enc = Rijndael.Create() wikiLink = "http://en.wikipedia.org/wiki/Rijndael_encryption_algorithm" Case Me.rbTripleDes.Checked enc = TripleDes.Create() wikiLink = "http://en.wikipedia.org/wiki/Triple_DES" End Select Me.lblWikiLink.Text = wikiLink Return enc End Function #End Region End Class 'Methods