VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This is a very basic encryption program that converts the message into alternating decimal and hex.

by Mark Delcambre (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 4th April 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This is a very basic encryption program that converts the message into alternating decimal and hex.

Rate This is a very basic encryption program that converts the message into alternating decimal and hex.




'This is a very simple encryption program. It switches between
'decimal and hex conversion for each character.

Private Sub cmdDecrypt_Click()
    Dim sIn As String
    Dim out As String
    Dim lx As Long
    Dim num As Long
    Dim MyArray() As String
    On Error GoTo unknown
       
    out = ""
    sIn = Trim(txtMessage.Text)
    txtMessage.Text = ""
    MyArray = Split(sIn, Chr(32))   'chr(32) is a space or " "
    For lx = 0 To UBound(MyArray())
        If lx Mod 2 = 0 Then
            'if its an even number then read in ascii
            out = out & Chr(MyArray(lx))
        Else
            'if odd, read in hex
            out = out & Chr(CLng("&h" & MyArray(lx)))
        End If
    Next
    If Len(out) = 0 Then
        MsgBox "Put numbers or something"
    End If
    txtMessage.Text = out
    Exit Sub
unknown:
    MsgBox "Unknown encryption!", vbCritical, "Error"
End Sub

Private Sub cmdEncrypt_Click()
    Dim Original As String
    Dim out As String
    Dim lx As Long
    Dim char As String
          
    out = ""
    Original = txtMessage.Text
    txtMessage.Text = ""
    For lx = 1 To Len(Original)
            If lx Mod 2 = 0 Then
                'if even, write in hex
                char = Mid(Original, lx, 1)
                out = out & Hex(Asc(char)) & " "
            Else
                'if odd, write in dec
                char = Mid(Original, lx, 1)
                out = out & Asc(char) & " "
            End If
    Next
    txtMessage.Text = out
End Sub

Private Sub Form_Load()
    txtMessage.Text = ""
    txtMessage.SetFocus
End Sub


Download this snippet    Add to My Saved Code

This is a very basic encryption program that converts the message into alternating decimal and hex. Comments

No comments have been posted about This is a very basic encryption program that converts the message into alternating decimal and hex.. Why not be the first to post a comment about This is a very basic encryption program that converts the message into alternating decimal and hex..

Post your comment

Subject:
Message:
0/1000 characters