Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[release] my eh... text encryption tool?!

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
squrrilslayer
Master Cheater
Reputation: 0

Joined: 26 Dec 2006
Posts: 323

PostPosted: Tue Nov 20, 2007 6:17 am    Post subject: [release] my eh... text encryption tool?! Reply with quote

http://www.megaupload.com/?d=DKJ9VW13

its a small text encryptor/decryptor made as a class activity. could be useful...

its using the XOR function (as in it uses XOR to encrypt/decrypt).

all ye who want source....
oh yeh, its VB 2005~
Code:

Imports System
Imports System.IO
Imports System.Security
Imports System.Security.Cryptography
Imports System.Runtime.InteropServices
Imports System.Text

Public Class MainPage
    Public FileLocation As String
    Public File As FolderBrowserDialog
    Public Encrypted As Boolean

    Private Sub btnReadFF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadFF.Click
        Dim FileNum As Integer = FreeFile()
        Dim TempString As String = ""
        If txtPath.Text = "" Then
            MsgBox("Please select a file. This can be done by clicking the Open File button", MsgBoxStyle.Exclamation, "Open File")
        Else
            FileOpen(FileNum, txtPath.Text, OpenMode.Input)
            Do Until EOF(FileNum)
                TempString &= LineInput(FileNum) & vbCrLf
            Loop
        End If
        FileClose(FileNum)
        txtText.Text = TempString

    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        txtText.Text = ""
    End Sub

    Private Sub btnWriteTF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWriteTF.Click
        Dim Filenum As Integer = FreeFile()
        If txtPath.Text = "" Then
            MsgBox("There is no where to write to. Please select a file by clicking the open file button")
            GoTo Jump1
        End If
        If MsgBox("Are you sure you wish to write to this file? Writing to a pre-encrypted file may cause unexpected behaviors with the file.", MsgBoxStyle.YesNo, "Caution") = MsgBoxResult.Yes Then
            FileOpen(Filenum, txtPath.Text, OpenMode.Output)
            PrintLine(Filenum, txtText.Text)
            FileClose(Filenum)
        Else
        End If
Jump1:


    End Sub
    'code storage:
    'Open "C:\yourfile.txt" For Append As #1      (this is for creating a file (the Append part))

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetFile.Click
        Dim browser As New OpenFileDialog
        browser.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
        If browser.ShowDialog = DialogResult.OK Then
            txtPath.Text = browser.FileName
        End If
    End Sub


    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtText.ScrollBars = ScrollBars.Both
        btnTest.Visible = False
    End Sub

    Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click
        If Encrypted = True Then
            MsgBox("This is already Encrypted")
        Else
            If txtKey.Text = "" Then
                MsgBox("Please input a key")
            Else
                Dim CharPos, i As Integer
                Dim Text As String = txtText.Text
                Dim EncryptedText As String = ""
                Dim key As Char = txtKey.Text.Chars(0)
                Dim CurrentChar, KeyPos As Char
                Dim Storage As Integer

                For i = 0 To (txtKey.TextLength - 1)
                    EncryptedText = ""
                    KeyPos = txtKey.Text.Chars(i)
                    For CharPos = 0 To (Text.Length - 1)
                        CurrentChar = Text.Chars(CharPos)
                        Storage = (Asc(CurrentChar) Xor Asc(KeyPos))
                        If Storage = 0 Then
                            EncryptedText &= CurrentChar
                            'MsgBox("Storage = " & Storage & "text stored:" & EncryptedText)
                        Else
                            'MsgBox("Storage does not = 0. Storage = " & Storage)
                            EncryptedText &= Chr(Asc(CurrentChar) Xor Asc(KeyPos))
                        End If

                    Next
                    Text = EncryptedText
                Next
                txtText.Text = EncryptedText
                Encrypted = True
            End If
        End If
    End Sub

    Private Sub btnDecrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecrypt.Click
        If Encrypted = False Then
            MsgBox("This is already Decrypted")
        Else
            If txtKey.Text = "" Then
                MsgBox("Please input a key")
            Else
                Dim CharPos, i, StartPos As Integer
                Dim Text As String = txtText.Text
                Dim DecryptedText As String = ""
                'Dim key As Char = txtKey.Text.Chars(0)
                Dim CurrentChar, KeyPos As Char
                Dim Storage As Integer
                StartPos = txtKey.Text.Length - 1
                For i = StartPos To 0 Step -1
                    DecryptedText = ""
                    KeyPos = txtKey.Text.Chars(i)
                    For CharPos = 0 To (Text.Length - 1)
                        CurrentChar = Text.Chars(CharPos)
                        Storage = (Asc(CurrentChar) Xor Asc(KeyPos))
                        If Storage = 0 Then
                            DecryptedText &= CurrentChar
                        Else
                            DecryptedText &= Chr(Asc(CurrentChar) Xor Asc(KeyPos))
                        End If

                    Next
                    Text = DecryptedText
                Next
                txtText.Text = DecryptedText
                Encrypted = False
            End If
        End If
    End Sub


    Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
        Dim CharPos, i As Integer
        Dim Text As String = txtText.Text
        Dim EncryptedText As String = ""
        Dim key As Char = txtKey.Text.Chars(0)
        Dim CurrentChar, KeyPos As Char
        Dim Storage As Integer
        For i = 0 To (txtKey.TextLength - 1)
            EncryptedText = ""
            KeyPos = txtKey.Text.Chars(i)
            For CharPos = 0 To (Text.Length - 1)
                CurrentChar = Text.Chars(CharPos)
                Storage = (Asc(CurrentChar) Xor Asc(KeyPos))
                If Storage = 0 Then
                    EncryptedText &= CurrentChar
                    'MsgBox("Storage = " & Storage & "text stored:" & EncryptedText)
                Else
                    'MsgBox("Storage does not = 0. Storage = " & Storage)
                    EncryptedText &= Chr(Asc(CurrentChar) Xor Asc(KeyPos))
                End If

            Next
            Text = EncryptedText
        Next
        txtText.Text = EncryptedText
    End Sub


    Private Sub btnEncReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncReset.Click
        Encrypted = False
        MsgBox("Encrypted has been set to False")
    End Sub

    Private Sub btnDecReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecReset.Click
        Encrypted = True
        MsgBox("Encrypted has been set to True")
    End Sub
End Class

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites