Can anyone help me create a file encryption/decryption prog.
I've made a registry prog. but now i need a way to encrypt and decrypt the file containing the password!! HELP
P.S. I'm pretty rusty in this area so make it easy to understand!~
Printable View
Can anyone help me create a file encryption/decryption prog.
I've made a registry prog. but now i need a way to encrypt and decrypt the file containing the password!! HELP
P.S. I'm pretty rusty in this area so make it easy to understand!~
Searching this very site turned up a lot of results. But this thread seems helpful:
http://forums.vb-world.net/showthrea...threadid=17689
'Encrypt/Unencrypt a file
'
Option Explicit
'
Private Function EncryptFile(sFile As String, iKey As Integer)
Dim iFake#
Dim x As String * 1
Dim lP As Long, z
Dim intNum#
intNum = FreeFile
iFake = Rnd(-1)
Randomize (iKey)
lP = 1
Open sFile For Binary As intNum
While lP <= LOF(intNum)
Get #intNum, lP, x
z = Asc(x) + Int(Rnd * 256)
If z > 255 Then z = z - 256
x = Chr(z)
Put #intNum, lP, x
lP = lP + 1
Wend
Close #intNum
MsgBox "Your file has been encrypted."
End Function
Private Function DecryptFile(sFile As String, iKey As Integer)
Dim iFake As Integer
Dim x As String * 1
Dim lP As Long, z
Dim intNum#
intNum = FreeFile
iFake = Rnd(-1)
Randomize (iKey)
lP = 1
Open sFile For Binary As #intNum
While lP <= LOF(intNum)
Get #intNum, lP, x
z = Asc(x) - Int(Rnd * 256)
If z < 0 Then z = z + 256
x = Chr(z)
Put #intNum, lP, x
lP = lP + 1
Wend
Close #intNum
MsgBox "Your file has been unencrypted."
End Function
' <<<< Form Event Code >>>>
Private Sub Command1_Click()
Call EncryptFile("a:\book1.xls", 44)
End Sub
Private Sub Command2_Click()
Call DecryptFile("a:\book1.xls", 44)
End Sub
You can also use the Xor operator with encryption keys.
Then reserve the process to decrypt it.Code:MyCode = 50
MyVal = 65 Xor MyCode
Code:MyCode = 50
MyVal = 115 Xor MyCode