Search This Blog

Wednesday, March 24, 2010

A simple encryption and decryption, used in vb.net

    Public Function Simple_encrption_decryption(ByVal Text As String) As String
        ' Encrypts/decrypts the passed string using
        ' a simple ASCII value-swapping algorithm
        Dim strTempChar As String, i As Integer
        strTempChar = ""
        For i = 1 To Len(Text)
            If Asc(Mid$(Text, i, 1)) < 133 Then
                strTempChar = CType(Asc(Mid$(Text, i, 1)) + 133, String)
            ElseIf Asc(Mid$(Text, i, 1)) > 133 Then
                strTempChar = _
          CType(Asc(Mid$(Text, i, 1)) - 133, String)
            End If
            Mid$(Text, i, 1) = Chr(CType(strTempChar, Integer))
        Next i
        Return Text
    End Function
-----------------------------------------
Pass a STRING you will get new encrypted string .
Pass ENCRYPTED sting you will get orignal string.

No comments:

Post a Comment