Encoding / encryption function

chamber11
01-12-2008, 04:59 AM
I am looking for a way to encrypt/decrypt a short string in Visual Basic 6.

However, the problem is that I need an identical encrypt/decrypt function for PHP, that will change the string in exactly the same way.

Does anyone know what I might be able to use?

:confused:

the master
01-12-2008, 11:13 AM
Yup. I just happen to have examples laying around. The PHP example is from the php site itself. I cant find the link but someone posted it on there. The VB version is what i wrote (except for the MD5 bit) based on that PHP code.

They need a key to work. Any MD5 hash will work for example "a1e31520b1086df12f518fc4113cd8fe"

Edit: I apologise for the lack of comments in my code. I didnt think anyone would ever want to see it

chamber11
01-12-2008, 04:59 PM
Hey, thanks a lot for this! It looks perfect for what I need. :)

chamber11
01-12-2008, 07:06 PM
I am having one problem.

When I try to send encoded data through Winsock, a lot of the time I get a 400 bad Request HTTP error.

Do you know of a function that I could perform on the data so it can be sent smoothly through HTTP?

the master
01-13-2008, 05:11 AM
You cant send binary data (which is what you get) straight to a HTTP server. You need to use boundaries and encode the data being sent.

There is a simpler solution though. You can encode your data into hex and send it like normal without needing boundaries. This does mean that you have to decode it yourself on the server (through code obviously). Hex values are 0-9 and A-F so they are plain text. The downsides are the extra processing which doesnt matter much for small amounts of data and the data sent is twice as big as the origional data but im not sure if you get that with other encode methods too

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum