|
-
Oct 30th, 2005, 04:42 AM
#1
Thread Starter
Addicted Member
Encryption a Text file ?
can VB6 encrypt and later decrypt a text file so file can only be run in my program ?
-
Oct 30th, 2005, 04:51 AM
#2
Fanatic Member
Re: Encryption a Text file ?
Yes it can. You can use this function to encrypt/decrypt a string:
VB Code:
Public Function RndCrypt(ByVal Str As String, ByVal Password As String) As String
Dim SK As Long, K As Long
' init randomizer for password
Rnd -1
Randomize Len(Password)
' (((K Mod 256) Xor Asc(Mid$(Password, K, 1))) Xor Fix(256 * Rnd)) -> makes sure that a
' password like "pass12" does NOT give the same result as the password "sspa12" or "12pass"
' or "1pass2" etc. (or any combination of the same letters)
For K = 1 To Len(Password)
SK = SK + (((K Mod 256) Xor Asc(Mid$(Password, K, 1))) Xor Fix(256 * Rnd))
Next K
' init randomizer for encryption/decryption
Rnd -1
Randomize SK
' encrypt/decrypt every character using the randomizer
For K = 1 To Len(Str)
Mid$(Str, K, 1) = Chr(Fix(256 * Rnd) Xor Asc(Mid$(Str, K, 1)))
Next K
RndCrypt = Str
End Function
So you can encrypt the text file, then print it to a txt file and when reading it in your program, decrypt it.
Hope this helps,
-
Nov 25th, 2005, 09:15 PM
#3
Fanatic Member
Re: Encryption a Text file ?
 Originally Posted by shirazamod
So you can encrypt the text file, then print it to a txt file and when reading it in your program, decrypt it.
Hope this helps,
the module cannot encrypt/decrypt a large text file.
-
Nov 25th, 2005, 10:19 PM
#4
Frenzied Member
Re: Encryption a Text file ?
there is a code in the codebank for creating unbreakable code. have a look at it.
-
Nov 26th, 2005, 07:41 AM
#5
Frenzied Member
Re: Encryption a Text file ?
the module cannot encrypt/decrypt a large text file.
Modpluz, could you please throw some more light on why the code posted by Shirazamod won't encrypt/decrypt large text files?
I just don't have any knowledge in encryption & decryption.
Thanks,
Arpan
-
Nov 26th, 2005, 07:55 AM
#6
Re: Encryption a Text file ?
http://www.vbforums.com/showthread.php?t=368001
Thats to the "Unbreakable" code, it would need alot of modifying to work for your needs, but the principals of unbreakable code are there.
Also, do a quick search of the codebank for "encryption" you should get many results
-
Nov 26th, 2005, 05:35 PM
#7
Fanatic Member
Re: Encryption a Text file ?
Arpan, do you mind running it?
with a large text file...
Last edited by modpluz; Nov 26th, 2005 at 05:48 PM.
-
Nov 26th, 2005, 10:34 PM
#8
Re: Encryption a Text file ?
 Originally Posted by shirazamod
Yes it can. You can use this function to encrypt/decrypt a string:
So you can encrypt the text file, then print it to a txt file and when reading it in your program, decrypt it.
Hope this helps,
shirazamod, Next time you copy and paste my code, can specify that it was made by me ?
Or you can simply post the link to the original thread, like this:
VB - 31 Bit Encryption function
It's really not nice when pasting someone else's code, withought posting who's the creator for it...
And modpluz is rignt, you should not use my encryption if the file is over aproximatelly 1 MByte...
In order to encrypt the file with my encryption you have to load the whole file at once to encrypt it.
That's assuming you don't know how to load and encrypt with small buffers. But if you do know how to work with buffers, then I see no problem in using my code with any size of file.
Last edited by CVMichael; Nov 26th, 2005 at 10:43 PM.
-
Nov 26th, 2005, 10:42 PM
#9
Re: Encryption a Text file ?
-
Nov 26th, 2005, 10:58 PM
#10
Re: Encryption a Text file ?
I've gotten nixed for that in the past, even though I didn't remember that ROBDOG888 had posted it.
-
Nov 27th, 2005, 02:33 AM
#11
Frenzied Member
Re: Encryption a Text file ?
i do have a piece of code which will work on large files too. this code is actually for string compression so basically who doesnot know the underlying algorithm will find it unreadable.
NOTE: NOT MY CODE
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
|