Ali Hmer
Ali Hmer

Reputation: 5071

Base64 string Compression

I have got an ActiveX Control that gets an image from a fingerprint device as base64 string. The Active works great and I could transfer the returned base64 string to the server to be converted to a binary data and then to be saved to a database. I use ASP.NET as server side technology and JavaScript as client side technology. The problem is that the base64 string is tool large and it would take from 30 to 40 seconds for the string to be transferred to the server. My question is: Is there any way to compress this base64 string on client (Browser) and deflate it back on server.

Upvotes: 2

Views: 9282

Answers (3)

James Watkins
James Watkins

Reputation: 127

Base64 is a format that is usually only used to get around technical limitaions of sending binary data. For example, a base64 string could be used in a GET request, like "website.com/page?q=BASE64ENCODED".

You have two options:

Figure out how to send/recieve binary data in a POST request, then send the data in a different form and convert it appropriately on the server. -OR- Since this is a fingerprint device, I assume you're using it as a password, so you actually don't have to send the raw fingerprint data every time. Just make an SHA-1 hash of it, and compare it to a stored hash on the server. This is just as secure and will take a fraction of a second to upload.

Hope I helped!

Upvotes: 1

user124493
user124493

Reputation:

on my linux system, using the bzip2 utility (which uses burrows-wheeler transform and then compresses), I reduce a jpg encoded in Base64 from 259.6KB to 194.5KB.

Using gzip (which uses an LZ algorithm of some variety), I reduce it to 194.4KB.

So, yes you can compress it. the question is why do you want to? It sounds as though your problems are really lying elsewhere.

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1499800

If the base64 image is really a jpeg or some other compressed image format, I wouldn't expect you to be able to get much extra compression out of it in the first place. You'd also need to work out a way of posting the binary compressed data afterwards in a portable way, which may not be terribly easy. (You may be able to pretend it's a file or something like that.)

Just how large is this image? 30 seconds is a very long time...

Upvotes: 3

Related Questions