-1

I am creating a mail client in Sails Js. I am using bcrypt encryption technique to store my content in Mysql so that even I can not see what are the contents stored in Database like Whatsapp. But how can I make the search so fast so that it can it took text from search box and encrypt it and then find matched text and bring that email ?

Thank You

  • Why do you want to store content in encrypted form? If security, then what kind of threats you want to avoid is important to know here. – Sangharsh Mar 01 '17 at 09:03
  • Because its a mail content. So much like Whatsapp who can not even see user message but still can search from that encrypted text. SO whatsapp is working ? – Bibudha R Sahoo Mar 01 '17 at 09:45
  • My guess is Whatsapp can't read messages on their server (encryption) and search happens on the app where message are not encrypted. – Sangharsh Mar 01 '17 at 10:09
  • Oh I see...and what about Gmail ? are they going too high so we can not even think of it.. – Bibudha R Sahoo Mar 01 '17 at 10:13
  • I believe, emails are stored in **un**-encrypted form in Gmail. (They are encrypted in [transit](https://www.google.com/transparencyreport/saferemail/faq/)) – Sangharsh Mar 01 '17 at 10:17
  • Thank You very much...lots of doubt are cleared now.... – Bibudha R Sahoo Mar 01 '17 at 11:56

1 Answers1

0

Bcrypt is a hashing library, not encryption (see).

It is not possible to get original content back from a hash. And it is not possible to search in it as well.

Even when using encryption if you encrypt say abc and your search term is a, only way to get abc as matching document is decrypt it before searching.

Edit:

Encryption methods don't have distributive property.

For e.g., multiplication is distributive (over addition) i.e.

a(b + c) = ab + ac

Let's say enc() is some basic encryption method then:

enc('A' + 'B') ≠ enc('A') + enc('B') // For most of encryption algorithms, otherwise breaking it will be much easier.
Community
  • 1
  • 1
Sangharsh
  • 2,999
  • 2
  • 15
  • 27