evil0zero

Base64 encoding + bzip2 compression

5 posts in this topic

im starting a project that takes base64 encoding as a form of file encryption and bzip2 compressing the file in one shot. im having trouble implementing the bzip2 functions base64 works fine but when it comes to converting a string to char its hell because the BZ2_bzBuffToBuffCompress(); function takes char. and it will not compile. im a beginner in c/cpp so my code isnt clean, i figured when i had a working draft i would make it clean and commented. complete source is in the file attachment someone help. i made a build script that builds all the dependencies like bzip2 components and then linked into the final program the file is build.sh. this program is cross platform(to my knowledge) windows devel is welcome.

for vc express all you need to do is add all your sources and compile it should work it should just link all the object files and be fine.

bz64.zip

0

Share this post


Link to post
Share on other sites

I did take a quick look at your code, and it does seem to be a casting mishap. You're mixing strings and char*'s all over the place. Plus your method for reading the files is not too great (you should be using the read method of your fstream objects).

I'm just struck by the uselessness of the whole thing. I understand this is just a learning project, but one generally encodes something in base64 to push it over an ascii protocol. You should be compressing with bzip then base64 encoding. That would at least make some sense. Remember that base64 encoding adds 33% to the data size, but it also splits each byte up. If you compress base64 data, you'll lose all meaningful patterns in the original data since each byte is now spread across two base64 characters.

0

Share this post


Link to post
Share on other sites

it does work seamlessly but im trying to simplify the process of base64 < "random file" > "random outputfile"; bzip2 -zvv "random outputfile"; ive tried this on binary files and it works the files apear to be fine after reversing the process. bzip2 was an excellent candidate because of its compression and fallback sorting algorithm. the idea was to scramble the file so it wouldnt be easy to know what the encoded data was but to compensate for the data increase, it would be logical to compress the data for transfer.

Edited by Mikhail
0

Share this post


Link to post
Share on other sites

It won't be difficult to figure out it's bzip2 compressed. Once that's done, it'll be obvious that it's base64 encoded. Don't use encodings and compression when what you want is encryption. Check out pgp or gpg if you want to exchange encrypted files.

What you want to do could be done like this though:

base64 <file | bzip2 -zvv >file.bz2

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now