28 Temmuz 2013 Pazar
TEXT ŞİFRELEME ÖRNEK KODU
20.08.2013 Güncellendi
TEXT ŞİFRELEME ÖRNEK KODU
İNDİR
Public Class Form1 Dim DsySaklaDialog As New SaveFileDialog With {.Filter = "Şifreli Dosyalar|*.giz"} Dim ButunTxt, secenek, u As String Private DsyAdi As String Dim textSonu As New TextBox Dim y As Int32 Dim zx As String Public TxtOku As IO.StreamReader Public Yaz As IO.StreamWriter Private Sub DosyaAçBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DosyaAçBtn.Click Dim DsyAcDialog As New OpenFileDialog DsyAcDialog.Filter = "Şifreli Dosyalar|*.giz|Text Dosyalar|*.txt" DsyAcDialog.InitialDirectory = Application.StartupPath If DsyAcDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Windows.Forms.Cursor.Current = Cursors.AppStarting If DsyAcDialog.FilterIndex = 1 Then Me.Text = "Text Şifrelemek ve Açmak" & " - " & IO.Path.GetFileNameWithoutExtension(DsyAcDialog.FileName) ButunTxt &= IO.File.ReadAllText(DsyAcDialog.FileName) Dim s As String = "abcçdefgğhıijklmnoöpqrsştuüvwxyz" For Each st In s ButunTxt = ButunTxt.Replace(st, "") Next ButunTxt = ButunTxt.Replace(":", vbNewLine) IO.File.WriteAllText("tx.txt", ButunTxt) For Each Me.zx In IO.File.ReadAllLines("tx.txt") y = Convert.ToInt32(zx) u &= Convert.ToChar(y) Next TextBox1.Text = u ButunTxt = String.Empty u = String.Empty IO.File.Delete("tx.txt") Else TextBox1.Clear() TextBox1.Text = IO.File.ReadAllText(DsyAcDialog.FileName) Me.Text = "Text Şifrelemek ve Açmak" & " - " & IO.Path.GetFileNameWithoutExtension(DsyAcDialog.FileName) End If End If End Sub Dim say As Int32 Private Sub ŞifreliSaklaBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ŞifreliSaklaBtn.Click If TextBox1.Text = Nothing Then Else DsySaklaDialog.InitialDirectory = Application.StartupPath If DsySaklaDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Windows.Forms.Cursor.Current = Cursors.AppStarting textSonu.Text = TextBox1.Text Application.DoEvents() For Each t In textSonu.Text say += 1 If say = 1 Then secenek &= Convert.ToInt32(t) & ":abcçdefgğhıijklmnoöpqrsştuüvwxyz" ElseIf say = 2 Then secenek &= Convert.ToInt32(t) & ":zyxwvüutşsrqpöonmlkjiıhğgfedçcba" ElseIf say = 3 Then secenek &= Convert.ToInt32(t) & ":öonmlkjiıhğgfedçcbazyxwvüutşsrqp" say = 0 End If Next IO.File.WriteAllText(DsySaklaDialog.FileName, secenek) SilBtn.PerformClick() End If End If End Sub Private Sub SilBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SilBtn.Click TextBox1.Text = String.Empty ButunTxt = String.Empty secenek = String.Empty textSonu.Text = String.Empty End Sub Private Sub TxtOlarakSaklaBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtOlarakSaklaBtn.Click Try With DsySaklaDialog .AddExtension = True .CheckPathExists = True .CreatePrompt = False .OverwritePrompt = True .ValidateNames = True .ShowHelp = True .DefaultExt = "txt" .FileName = DsyAdi .Filter = "Text Dosyaları (*.txt)|*.txt" .FilterIndex = 1 If .ShowDialog() = Windows.Forms.DialogResult.OK Then My.Computer.FileSystem.WriteAllText(.FileName, TextBox1.Text, False) End If End With Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try End Sub Private Sub ŞifreliMetniAçBtn_Click(sender As System.Object, e As System.EventArgs) Handles ŞifreliMetniAçBtn.Click Dim openDLG As New OpenFileDialog openDLG.DefaultExt = "giz" openDLG.Filter = "Şifreli Dosyalar(*.giz|*.giz" If openDLG.ShowDialog = Windows.Forms.DialogResult.OK Then Windows.Forms.Cursor.Current = Cursors.AppStarting Dim uzanti As String uzanti = System.IO.Path.GetExtension(openDLG.FileName) uzanti = uzanti.ToLower Select Case uzanti Case ".giz" TextBox1.Clear() 'TxtOku = New IO.StreamReader(openDLG.FileName, System.Text.Encoding.Default) 'TxtOku = New IO.StreamReader(openDLG.FileName, System.Text.Encoding.Unicode) TxtOku = New IO.StreamReader(openDLG.FileName, System.Text.Encoding.UTF8) 'TxtOku = New IO.StreamReader(openDLG.FileName, System.Text.Encoding.ASCII) 'TxtOku = New IO.StreamReader(openDLG.FileName, System.Text.Encoding.GetEncoding(1254)) TextBox1.Text = TxtOku.ReadToEnd TxtOku.Close() TxtOku = Nothing TextBox1.Focus() Case Else Try System.Diagnostics.Process.Start(openDLG.FileName) Catch ex As Exception MessageBox.Show(uzanti & " 'Uzantılı uygulama Bulunamadı.", " Hata", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Exit Sub End Select End If End Sub End Class
Sonraki Kayıt
Önceki Kayıt
Ana Sayfa