|
-
Dec 7th, 2005, 11:05 PM
#1
Thread Starter
Junior Member
Encryption & Decryption with office files
This method works only for notepad files.
i want it to mainly work with office files.
when i decrypt i want to generate the original office file which i encrypted. but this code after decryption generates the decrypted version of offcie file in a notepad file and also has a lot of junk characters in it.
If this doesnot work is there any other way out. Probably using APIs
Please help
----encryption----------
Public Function funcencrypt(PassText As String) As String
Dim lpos As Long ' For Iterating through each byte in Source File
Dim bdata As Byte ' For Reading Data from Source File
Dim bdatac As Byte ' For storing Complemented (or encrypted) bData
lpos = 1
'opening the file where encrypted data will be stored
Open PassText & ".encrypted" For Binary Access Write As #2
'opening the source file to be encrypted
Open PassText For Binary Access Read As #1
Do While Not EOF(1)
Get #1, lpos, bdata 'Reading Data Byte by Byte from Source File
bdatac = Not (bdata) 'Encryption of the Data
If Not bdatac = 255 Then
Put #2, lpos, bdatac 'Writing Encrypted Data To Temporary Destination File
End If
lpos = lpos + 1
Loop
Close #1
Close #2
End Function
------------Decryption---------------------
Public Function funcdecrypt(PassText As String) As String
Dim lpos As Long ' For Iterating through each byte in Source File
Dim bdata As Byte ' For reading data from the temporary file
Dim bdatac As Byte ' for storing data to another temporary file
lpos = 1
'opening the file where decrypted data will be stored
Open PassText & ".encrypted" For Binary Access Write As #2
Open PassText For Binary Access Read As #1
Do While Not EOF(1)
Get #1, lpos, bdata
bdatac = Not (bdata)
If Not bdatac = 255 Then
Put #2, lpos, bdatac
End If
lpos = lpos + 1
Loop
Close #1
Close #2
End Function
Last edited by nish_menon; Dec 7th, 2005 at 11:08 PM.
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
|