Encrypt OR Decrypt a String Using ASCII Character in Dot Net.

Using this we can Encrypt OR Decrypt a String for security Purpose.
Using this we can EnCrypt the password & save in Back end. Then while retrieving again we can Decrypt the password.


Code :
    Public Class frmEnCryptDeCrypt

    #Region "btnEnCryptDeCrypt Click"
        Private Sub btnEnCryptDeCrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnCryptDeCrypt.Click
            txtResult.Text = fnEnCryptDeCrypt(txtInput.Text)
        End Sub
    #End Region

    #Region "EnCrypt or DeCrypt String"
        Public Function fnEnCryptDeCrypt(ByVal Text As String) As String
            Dim strTempChar As String = "", i As Integer
            For i = 1 To Len(Text)
                If Asc(Mid$(Text, i, 1)) < strtempchar = " CType(Asc(Mid$(Text," > 128 Then
                    strTempChar = CType(Asc(Mid$(Text, i, 1)) - 128, String)
                End If
                Mid$(Text, i, 1) = Chr(CType(strTempChar, Integer))
            Next i
            Return Text
        End Function
    #End Region

    End Class

No comments:

Post a Comment