2

What are the pro's and con's of each?

My requirements are:

  1. I want to be able to encrypt the image
  2. Easily accessible on a mobile device through a webserver (RESTful API)
  3. Easily accessible on a mobile device through a local database like SQLLite

The databases im using on the server side is MS SQL 2005. I beleive SQLLite and MS SQL 2005 can support both varchar and varbinary (BLOB on sqllite)

fes
  • 2,465
  • 11
  • 40
  • 56
  • Does this answer your question? [Storing image in database directly or as base64 data?](https://stackoverflow.com/questions/9722603/storing-image-in-database-directly-or-as-base64-data) – Gert Arnold Mar 26 '23 at 07:41

1 Answers1

4

Base64 only uses 6 out of 8 bits in a byte. It dates back to the time when emails were transmitted over lines that were not 7 bits safe.

Back then, you'd store the image as a binary blob, because that required 33% less storage space. Then you'd convert it on the fly when a client requests a base64 encoded string. Conversion to base64 is very cheap.

That still makes sense today-- store it as a binary, transmit it like whatever the client requests.

Andomar
  • 232,371
  • 49
  • 380
  • 404
  • Thanks this is very helpful. I will now just need to check out the feasibility of encryping this binary data. – fes Jun 18 '11 at 10:58
  • @Andomar, what are the cons of storing the images as varchar(max) in the sql server database. There is no need for encryption here. I am already doing this and transmitting to the client as a 'string' via c#. – PhantomReference Jul 13 '16 at 06:33