0

I want to encrypt and decrypt data strings that are longer than 2500 characters. Is it possible to encrypt and decrypt such long data strings. It's like essays. Please tell me which encryption and decryption technique should I choose for such long data in PHP. Also what will be the effects of this on the database? Will the database will become heavy. What will be the length of the encrypted string that it will return?

I have never encrypted data in PHP rather than using only md5().

likeitlikeit
  • 5,563
  • 5
  • 42
  • 56

2 Answers2

0

MD5 is NOT encryption, it's a hash function, a one-way method to obfuscate data.

For encryption of data that you can also decrypt, take a look at Simplest two-way encryption using PHP.

Community
  • 1
  • 1
silkfire
  • 24,585
  • 15
  • 82
  • 105
0

md5() isn't usually used for encryption, but for hashing purposes.

There are many extensions in PHP that deal with encryption. You can find them all here: http://www.php.net/manual/en/refs.crypto.php

The most well known extensions are Mcrypt and OpenSSL.

With OpenSSL, you can use openssl_encrypt() to encrypt your data.

With Mcrypt, you can use mcrypt_encrypt() to encrypt your data.

Check the relevant sections of each extension for more information

Filippos Karapetis
  • 4,367
  • 21
  • 39
  • I understand. But which encryption technique is best to encrypt about 2500 character string? – Yashan Mittal Jun 14 '13 at 14:51
  • AES is a quite solid encryption algorithm. Check here: http://stackoverflow.com/questions/2809855/which-php-mcrypt-cipher-is-safest - this mentions mcrypt, but it's the same in the newer openssl extension – Filippos Karapetis Jun 14 '13 at 15:02