|
-
Aug 11th, 2000, 09:53 PM
#1
Thread Starter
Hyperactive Member
Hey, Using the code below, i want to be able to ENCRYPT a whole TEXT FILE...
I am not sure how i would make it ENCRYPT a whole file using this, So could someone make it workable? or maybe if someone has an encryption script maybe LIKE THIS ONE or better that will encrypt a FILE/ DECRYPT
::USE:: I am saving a bunch of program settings, and i don't want people to edit them,, so i want my program to SAVE ALL THE SETTINGS, to the file, ENCRYPT IT, and then when i want to open it, it will DECRYPT , and Read it (I have it so i can read it)..
THANKS ALOT
PS: or would i have to import it all into a textbox, and then encrypt the Textbox?? THANKS- i would like to get the program to encrypt it with out textfile.. thanks again
Code:
'<<------------------------------------------>>
'START EN/DE crypt PARTS
'<<==========================================>>
#Const CASE_SENSITIVE_PASSWORD = False
Private Sub cmdEncrypt_Click()
' You can encrypt twice for extra security
txtText = EncryptText((txtText), txtPassword)
txtText = EncryptText((txtText), txtPassword)
End Sub
Private Sub cmdDecrypt_Click()
txtText = DecryptText((txtText), txtPassword)
txtText = DecryptText((txtText), txtPassword)
End Sub
'Encrypt text
Private Function EncryptText(strText As String, ByVal strPwd As String)
Dim i As Integer, c As Integer
Dim strBuff As String
#If Not CASE_SENSITIVE_PASSWORD Then
'Convert password to upper case
'if not case-sensitive
strPwd = UCase$(strPwd)
#End If
'Encrypt string
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c + Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr$(c And &HFF)
Next i
Else
strBuff = strText
End If
EncryptText = strBuff
End Function
'Decrypt text encrypted with EncryptText
Private Function DecryptText(strText As String, ByVal strPwd As String)
Dim i As Integer, c As Integer
Dim strBuff As String
#If Not CASE_SENSITIVE_PASSWORD Then
'Convert password to upper case
'if not case-sensitive
strPwd = UCase$(strPwd)
#End If
'Decrypt string
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c - Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr$(c And &HFF)
Next i
Else
strBuff = strText
End If
DecryptText = strBuff
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|