Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to Mcrypt for encryption / decryption in PHP?

I'm giving some code for a Drupal module that needs to do encryption and decryption. I dont think I can assume that the Mcrypt module is installed on the Drupal system. What can i use as an alternative encryption mechanism?

This isnt for financial stuff, so i dont need sophisticated cryptology, but better is beter...

like image 263
siliconpi Avatar asked Feb 05 '26 02:02

siliconpi


2 Answers

How about using your database? MySQL has AES and DES encryption and decryption functions. You could then use a "fake" query to get your string:

select id, aes_encrypt('My secret text', 'the key string') 
from permissions 
limit 1

(MySQL returns an empty set if you don't have at least one field from the table.)

Decryption works the same way. It's 128-bit AES, which is not too bad, cryptographically, and if you can't even be sure about MCrypt, I doubt you will be recompiling MySQL to get 256-bit AES.

like image 136
Graham Avatar answered Feb 06 '26 14:02

Graham


There are several methods of encrypting PHP codes, using a key to encrypt/decrypt codes makes it more secure as an alternate to MCrypt.

One way is creating a function that may require a key to complete an encryption or decryption. PHP has its built-in functions like gzdeflate() or gzinflate(), another is using base64_encode()/base64_decode() and str_rot13() functions.

But I don't think using PHP Encoder would work.

like image 24
Leon Alexis Cardinal Avatar answered Feb 06 '26 16:02

Leon Alexis Cardinal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!