joe_pool_is Posted November 20, 2008 Posted November 20, 2008 I need a way to encrypt and then decrypt a stream of bytes. There are many techniques that I've found on how to encrypt a file, but decrypting the information so that it can be used again seems to be a secret. Has anyone run across something that shows how to encrypt then decrypt a file? Quote Avoid Sears Home Improvement
Administrators PlausiblyDamp Posted November 21, 2008 Administrators Posted November 21, 2008 If you are using a shared key method then you need to ensure that the same key / IV is used to encrypt and decrypt - there isn't any real magic involved. http://www.xtremedotnettalk.com/showthread.php?t=101639 has a quick example of how this can be done. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
joe_pool_is Posted November 21, 2008 Author Posted November 21, 2008 Wow! A nice, new tutorial in the Code Library! Thank you, PD! Quote Avoid Sears Home Improvement
joe_pool_is Posted November 21, 2008 Author Posted November 21, 2008 I hate to keep bothering you about this, but I've run into a related question: Given a file (could be an image, a zipped archive, a text file, PDF, etc), how could my application tell if the file has already been encrypted with my technique? I want to retain whatever extensions are already on the original file formats whenever they are encrypted and replace the original file with the encrypted version - unless they are already encrypted! If they are already encrypted, I want to decrypt them. I just don't know how to test for a file or a stream already being encrypted. Quote Avoid Sears Home Improvement
Administrators PlausiblyDamp Posted November 21, 2008 Administrators Posted November 21, 2008 Probably the easiest way is when writing the encrypted version make the file contents start with a particular byte sequence, when opening the file check for this sequence - if it exists then it needs to be decrypted if it doesn't assume it is already decrypted. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.