Website Design United States, Website Design California, Website Designing United States, Website Designing California

Simple and smart encrypter - Visual Basic 6

A programmer can include the code in a class and use the object of the class to encrypt and/or decrypt the string sending it to the object.

Option Explicit
'Declare public and private variables
Dim str1(95) As String
Dim str2(95) As String

Enum myCryptography
    Encrypt = 1
    Decrypt
End Enum

Private Function loadstring()
    str1(0) = "*": str1(1) = "_": str1(2) = " ": str1(3) = ")": str1(4) = "="
    str1(5) = "N": str1(6) = ";": str1(7) = "1": str1(8) = "I": str1(9) = "'"
    str1(10) = "U": str1(11) = "\": str1(12) = "<": str1(13) = "!": str1(14) = "a"
    str1(15) = "H": str1(16) = "R": str1(17) = "'": str1(18) = "h": str1(19) = "f"
    str1(20) = "[": str1(21) = "O": str1(22) = "(": str1(23) = "X": str1(24) = "t"
    str1(25) = "}": str1(26) = "Y": str1(27) = "r": str1(28) = "p": str1(29) = "~"
    str1(30) = "9": str1(31) = "L": str1(32) = "&": str1(33) = "D": str1(34) = "#"
    str1(35) = "7": str1(36) = "0": str1(38) = "V": str1(39) = ":": str1(40) = "2"
    str1(41) = ">": str1(42) = """": str1(43) = "s": str1(44) = "/": str1(45) = "8"
    str1(46) = "+": str1(47) = "@": str1(48) = "%": str1(49) = "]": str1(50) = "b"
    str1(51) = "Z": str1(52) = "J": str1(53) = "Q": str1(54) = ".": str1(55) = "d"
    str1(56) = "j": str1(57) = "l": str1(58) = "P": str1(59) = "e": str1(60) = "6"
    str1(61) = "{": str1(62) = "|": str1(63) = ",": str1(64) = "C": str1(65) = "n"
    str1(66) = "?": str1(67) = "$": str1(68) = "T": str1(69) = "3": str1(70) = "c"
    str1(71) = "B": str1(72) = "^": str1(73) = "5": str1(74) = "E": str1(75) = "A"
    str1(76) = "g": str1(77) = "v": str1(78) = "x": str1(79) = "i": str1(80) = "u"
    str1(81) = "4": str1(82) = "F": str1(83) = "S": str1(84) = "w": str1(85) = "q"
    str1(86) = "y": str1(87) = "k": str1(88) = "m": str1(89) = "z": str1(90) = "o"
    str1(91) = "M": str1(92) = "G": str1(93) = "K": str1(94) = "W": str1(37) = "-"
    'to the second string
    str2(0) = """": str2(1) = "-": str2(2) = "J": str2(3) = "B": str2(4) = "c"
    str2(5) = "P": str2(6) = "@": str2(7) = "1": str2(8) = "6": str2(9) = "#"
    str2(10) = " ": str2(11) = "N": str2(12) = "_": str2(13) = "E": str2(14) = "V"
    str2(15) = "L": str2(16) = "D": str2(17) = "'": str2(18) = "H": str2(19) = "e"
    str2(20) = "q": str2(21) = "i": str2(22) = "\": str2(23) = "C": str2(24) = "M"
    str2(25) = ">": str2(26) = "G": str2(27) = "&": str2(28) = ",": str2(29) = "$"
    str2(30) = "I": str2(31) = "b": str2(32) = "O": str2(33) = "k": str2(34) = "g"
    str2(35) = "'": str2(36) = "A": str2(37) = "j": str2(38) = "r": str2(39) = "|"
    str2(40) = "/": str2(41) = "(": str2(42) = "T": str2(43) = "}": str2(44) = "?"
    str2(45) = "{": str2(46) = "%": str2(47) = "5": str2(48) = "Z": str2(49) = "U"
    str2(50) = "0": str2(51) = "s": str2(52) = "d": str2(53) = "*": str2(54) = "F"
    str2(55) = "~": str2(56) = "7": str2(57) = ":": str2(58) = "S": str2(59) = "4"
    str2(60) = "+": str2(61) = "Q": str2(62) = "h": str2(63) = "!": str2(64) = ")"
    str2(65) = ".": str2(66) = "R": str2(67) = "f": str2(68) = "W": str2(69) = "["
    str2(70) = "3": str2(71) = "l": str2(72) = "2": str2(73) = "o": str2(74) = "X"
    str2(75) = "w": str2(76) = "Y": str2(77) = "x": str2(78) = "a": str2(79) = "z"
    str2(80) = "<": str2(81) = "u": str2(82) = ";": str2(83) = "K": str2(84) = "8"
    str2(85) = "p": str2(86) = "m": str2(87) = "t": str2(88) = "n": str2(89) = "v"
    str2(90) = "y": str2(91) = "]": str2(92) = "^": str2(93) = "9": str2(94) = "="
End Function

Private Sub Class_Initialize()
    loadstring  ' Call
End Sub

Private Function OphthyChange(txt As String, str() As String) As String
    Dim i As Integer
    Dim x As String, y As String
    For i = 1 To Len(txt)
        x = Mid$(txt, i, 1)
        
        If x = Chr(13) Then
            y = vbCrLf
            ' b/c the next char is chr(10):(i.e   vbCrLf=chr(13)+chr(10)
            i = i + 1
        ElseIf x = vbTab Then
            y = vbTab
        Else
            y = str(Asc(x) - 32)
        End If
        OphthyChange = y & OphthyChange
    Next i
End Function

'The public encryption method
Public Function EncryptDocument(ByVal IncomingText As String, Optional ProcessType As myCryptography = Encrypt) As String
    Dim xx As String
    If ProcessType = Encrypt Then
        xx = OphthyChange(IncomingText, str1)
    Else
        xx = OphthyChange(IncomingText, str2)
    End If
    EncryptDocument = xx
End Function


        


WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com