Temas > Programacion > Visual Basic > Encryptar y desemcryptar un texto en Visual Basic
Julio

Esta es una pequeña aplicación para poder encryptar un texto y luego
poder desemcryptarlo utilizando la tabla asci.
En nuestro form1 pondremos el siguiente codigo:
<?//esto no va
ïPublic Class Form1
    Dim LineaTexto As String
    Dim todo As String
    Dim encrip As String
    Dim cnt As Integer
    Dim cadena As String
    Dim convertidor As Integer
    Dim longitud As Integer
    Dim codificado As String
    Dim numero As Integer
    Dim acum As String
    Dim entrada As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
    End Sub
    Private Sub examinar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles examinar.Click
        OpenFileDialog1.ShowDialog()
        mostrar.Enabled = True
        todo = ""
        Try
            FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
            Do Until EOF(1)
                LineaTexto = LineInput(1)
                todo &= LineaTexto & vbCrLf
            Loop
        Catch ex As Exception
            MsgBox("El fichero no existe")
        Finally
            FileClose(1)
        End Try
        TextBox2.Text = OpenFileDialog1.FileName
    End Sub
    Private Sub mostrar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mostrar.Click
        TextBox1.Text = todo
        encriptado.Enabled = True
        guardar.Enabled = True
        Salir.Enabled = True
        borrar.Enabled = True
        desencriptado.Enabled = True
    End Sub
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.TextChanged
    End Sub
    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox2.TextChanged
    End Sub
    Private Sub borrar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles borrar.Click
        TextBox1.Text = ""
    End Sub
    Private Sub Salir_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Salir.Click
        End
    End Sub
    Private Sub guardar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles guardar.Click
        SaveFileDialog1.ShowDialog()
        Try
            If SaveFileDialog1.FileName <> "" Then
                FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output)
                PrintLine(1, TextBox1.Text)
                FileClose()
            End If
        Catch ex As Exception
            MsgBox("El fichero no existe")
        End Try
    End Sub
    Private Sub encriptado_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles encriptado.Click
        cadena = TextBox1.Text
        SaveFileDialog1.ShowDialog()
        cnt = 0
        codificado = ""
        longitud = TextBox1.Text.Length
        For index = 0 To longitud - 1
           encrip = cadena.Substring(cnt, 1)
            convertidor = 5 + Asc(encrip)
            codificado = codificado & convertidor
            codificado = codificado & "-"
            cnt = cnt + 1
        Next
        Try
            If SaveFileDialog1.FileName <> "" Then
                FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output)
                PrintLine(1, codificado)
                FileClose()
           End If
        Catch ex As Exception
            MsgBox("El fichero no existe")
        End Try
    End Sub
    Private Sub desencriptado_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles desencriptado.Click
        cadena = TextBox1.Text
        SaveFileDialog1.ShowDialog()
        cnt = 0
        entrada = 0
        codificado = ""
        longitud = TextBox1.Text.Length
        For index = 0 To longitud - 1
           encrip = cadena.Substring(cnt, 1)
            acum = acum & encrip
            If encrip <> "-" Then
                entrada = entrada + 1
            Else
                numero = acum.Substring(0, entrada) - 5
                codificado = codificado & Chr(numero)
                acum = ""
                entrada = 0
            End If
            cnt = cnt + 1
        Next
        Try
            If SaveFileDialog1.FileName <> "" Then
                FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output)
                PrintLine(1, codificado)
               FileClose()
            End If
        Catch ex As Exception
            MsgBox("El fichero no existe")
        End Try
    End Sub
End Class

?>//esto no va

Es una encryptacion sencilla pero eficaz













¿Has olviado tu contraseña?

Pulsa aquí para registrate




Google






LunMarMieJueVieSabDom
    123
45678910
11121314151617
181920 21222324
252627282930 

Jueves 21 de Noviembre 2024
Semana 47

..............................................................................................................................................................................................................................................
(Contacto)..
Esta web utiliza cookies para obtener datos estadísticos de la navegación de sus usuarios. Política de privacidad y Aviso legal