VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Effective Encryption Algorithm

by Micah Ellett (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

Encrypts and decrypts strings

Inputs
Simply: DMEncrypt "Text" and DMDecrypt "Text"
Assumes
Pretty straightforward
Code Returns
2 functions return a string value, either encrypted or decrypted text.
Side Effects
None that I know of

Rate Effective Encryption Algorithm

'THIS FUNCTION ENCRYPTS THE INPUT
Public Function DMEncrypt(strText As String)
On Error GoTo Xit
Dim Combine As String, i As Integer, Temp As String
Combine = ""
Temp = ""
For i = 1 To Len(strText) - 1 Step 2
  If Len(Trim(Str(Asc(Mid(strText, i, 1))))) < 3 Then
    Temp = "0" & Trim(Str(Asc(Mid(strText, i, 1))))
  Else
    Temp = Trim(Str(Asc(Mid(strText, i, 1))))
  End If
  Combine = Combine & Temp
  If Len(Trim(Str(Asc(Mid(strText, i + 1, 1))))) < 3 Then
    Temp = "0" & Trim(Str(Asc(Mid(strText, i + 1, 1))))
  Else
    Temp = Trim(Str(Asc(Mid(strText, i + 1, 1))))
  End If
  Combine = Combine & Temp
Next i
Temp = ""
For i = 1 To Len(Combine)
  Temp = Temp & Chr(Asc(Mid(Combine, i, 1)) + 128)
Next i
DMEncrypt = Temp
Clipboard.SetText Temp
Exit Function
Xit:
DMEncrypt = "{{ Error encrypting }}"
Exit Function
End Function
'THIS FUNCTION DECRYPTS THE INPUT
Public Function DMDecrypt(strText As String)
On Error GoTo Xit
Dim Combine As String, i As Integer, Temp As String, Temp2 As Integer
Combine = ""
For i = 1 To Len(strText)
  Combine = Combine & Chr(Asc(Mid(strText, i, 1)) - 128)
Next i
Temp = ""
For i = 1 To Len(Combine) Step 3
  Temp2 = Mid(Combine, i, 3)
  Temp = Temp & Chr(Temp2)
Next i
DMDecrypt = Temp
Exit Function
Xit:
DMDecrypt = "{{ Error encrypting }}"
Exit Function
End Function

Download this snippet    Add to My Saved Code

Effective Encryption Algorithm Comments

No comments have been posted about Effective Encryption Algorithm. Why not be the first to post a comment about Effective Encryption Algorithm.

Post your comment

Subject:
Message:
0/1000 characters