XOR

Encrypt
                            
     Dim letter As Char
     Dim strCode As String
     Dim i, charsInFile, Code As Integer
     Dim StreamToWrite As StreamWriter = Nothing

     SaveFileDialog1.Filter = "Text files (*.txt)|*.txt"
        If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
            Try
                strCode = InputBox("Enter a password pin number")
                    If strCode = "" Then
                        Exit Sub
                     End If

                    If Not IsNumeric(strCode) Then
                        MessageBox.Show("Your password pin must be numeric")
                        Exit Sub
                    End If

                Code = strCode
                charsInFile = txtNote.Text.Length
                StreamToWrite = My.Computer.FileSystem.OpenTextFileWriter(SaveFileDialog1.FileName, False)
                For i = 0 To charsInFile - 1
                    letter = txtNote.Text.Substring(i, 1)
                    StreamToWrite.Write(Asc(letter) Xor Code)
                    StreamToWrite.Write(" ")
                 Next
            Catch ex As Exception
                MsgBox("An error occurred." & vbCrLf & ex.Message)
            Finally
            If StreamToWrite IsNot Nothing Then
                StreamToWrite.Close()
            End If
            End Try
         End If
                            
                                

Encrypt
                            
     Dim AllText As String
     Dim i As Short
     Dim ch As Char
     Dim strCode As String
     Dim Code, Number As Integer
     Dim Numbers() As String
     Dim Decrypt As String = ""

     OpenFileDialog1.Filter = "Text files (*.txt)|*.txt"
     If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
        Try
            strCode = InputBox("Enter a password pin number")
            If strCode = "" Then
                Exit Sub
            End If

            If Not IsNumeric(strCode) Then
                MessageBox.Show("Your password pin must be numeric")
            Exit Sub
            End If

            Code = CInt(strCode)
            AllText = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
            AllText = AllText.Trim
            Numbers = AllText.Split(" ")

            For i = 0 To Numbers.Length - 1
                Number = CInt(Numbers(i))
                ch = Chr(Number Xor Code)
                Decrypt = Decrypt & ch
            Next
            txtNote.Text = Decrypt
            lblNote.Text = String.Format("Filename: {0}", OpenFileDialog1.FileName)
            txtNote.Select(0, 0)
            txtNote.Enabled = True

        Catch er As ArgumentException
            If er.Message = "Argument 'CharCode' must be within the range of -32768 to 65535." Then
                MessageBox.Show("Invalid Password")
                Exit Sub
            End If
        Catch ex As Exception
            MsgBox("An error occurred." & vbCrLf & ex.Message)
            End Try
     End If