VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



It encrypts and decrypts given string using simple logic.

by balu (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 1st November 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

It encrypts and decrypts given string using simple logic.

Rate It encrypts and decrypts given string using simple logic.



// This code works depending on the ascii value of the character


Private Sub cmddecrypt_Click()
Dim str1 As String
Dim strencrypt As String

Dim str1len As Integer
Dim chr1 As String
Dim i As Integer
Dim ascii As Integer

strencrypt = ""

str1 = cb.List(cb.ListIndex)

Debug.Print str1
str1len = Len(str1)
If str1len <> 0 Then
For i = 1 To str1len
chr1 = Mid(str1, i, 1)
ascii = Asc(chr1)
If ascii < 150 And ascii > 40 Then
ascii = ascii - 10
End If
strencrypt = strencrypt & Chr(ascii)
Next i
MsgBox "Decrypted string " & strencrypt, vbInformation + vbOKOnly, "Decrypt"
Else
MsgBox "Select a string to decrypt", vbInformation + vbOKOnly
End If


End Sub

Private Sub cmdencrypt_Click()
Dim str1 As String
Dim strencrypt As String

Dim str1len As Integer
Dim chr1 As String
Dim i As Integer
Dim ascii As Integer

strencrypt = ""
str = Trim(InputBox("Enter a string", "Encrypt"))
str1 = str
str1len = Len(str1)
If str1len <> 0 Then
For i = 1 To str1len
chr1 = Mid(str1, i, 1)
ascii = Asc(chr1)
If ascii < 150 And ascii > 40 Then
ascii = ascii + 10
End If
strencrypt = strencrypt & Chr(ascii)
Next i
cb.AddItem strencrypt
MsgBox "String Encrypted successfully!", vbInformation + vbOKOnly, "Encrypt"
Else
MsgBox "Enter a string", vbInformation + vbOKOnly
End If
End Sub

Private Sub Form_Load()
cmdencrypt.Caption = "Encrypt"
cmddecrypt.Caption = "Decrypt"
End Sub


Download this snippet    Add to My Saved Code

It encrypts and decrypts given string using simple logic. Comments

No comments have been posted about It encrypts and decrypts given string using simple logic.. Why not be the first to post a comment about It encrypts and decrypts given string using simple logic..

Post your comment

Subject:
Message:
0/1000 characters