VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Encryption and decryption program

by Pat-Dog (1 Submission)
Category: Encryption
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 14th March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Encryption and decryption program

API Declarations



'you need to make 2 command boxes called command1 and command2, also a text box called text1 and a label called label1

'click command1 to encrypt some text that u type in and save to file on c drive
click command2 to decrypt it from the file and bring it to the label

Rate Encryption and decryption program




Public Function Encrypt(ByVal Plain As String)
    Dim Letter As String
    For i = 1 To Len(Plain)
        Letter = Mid$(Plain, i, 1)
        Mid$(Plain, i, 1) = Chr(Asc(Letter) + 99)
    Next i
    Encrypt = Plain
End Function

Public Function Decrypt(ByVal Encrypted As String)
Dim Letter As String
    For i = 1 To Len(Encrypted)
        Letter = Mid$(Encrypted, i, 1)
        Mid$(Encrypted, i, 1) = Chr(Asc(Letter) - 99)
    Next i
    Decrypt = Encrypted
    
End Function

Private Sub Command1_Click()
password = Text1.Text
password = Encrypt(password)
Open "c:\file.txt" For Output As #1
Print #1, password
Close #1
End Sub

Private Sub Command2_Click()
Open "c:\file.txt" For Input As #1
    Input #1, password
    Close #1
    password = Decrypt(password)
    Label1.Caption = password
    End Sub

Download this snippet    Add to My Saved Code

Encryption and decryption program Comments

No comments have been posted about Encryption and decryption program. Why not be the first to post a comment about Encryption and decryption program.

Post your comment

Subject:
Message:
0/1000 characters