can VB6 encrypt and later decrypt a text file so file can only be run in my program ?
Printable View
can VB6 encrypt and later decrypt a text file so file can only be run in my program ?
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.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
Hope this helps,
the module cannot encrypt/decrypt a large text file.Quote:
Originally Posted by shirazamod
there is a code in the codebank for creating unbreakable code. have a look at it.
Modpluz, could you please throw some more light on why the code posted by Shirazamod won't encrypt/decrypt large text files?Quote:
the module cannot encrypt/decrypt a large text file.
I just don't have any knowledge in encryption & decryption.
Thanks,
Arpan
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 ;)
Arpan, do you mind running it?
with a large text file...
shirazamod, Next time you copy and paste my code, can specify that it was made by me ?Quote:
Originally Posted by shirazamod
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.
Also, this is a very strong encryption that works with large files:
VB - 128, 160 and 256 Bit File Encryption/Decryption with MD5, SHA1 and SHA256
I've gotten nixed for that in the past, even though I didn't remember that ROBDOG888 had posted it. :eek:
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