siliconpi
siliconpi

Reputation: 8287

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...

Upvotes: 3

Views: 3229

Answers (4)

MyXEDNotes
MyXEDNotes

Reputation: 209

based on Leon's answer, PHP Encoder is using MCrypt module that may not work on Drupal. Another way is is to use IonCube Encoder.

If you want a more strict function, you may also try to use hash() and md5() function to create your key and require it on you encrypting function with the returns of gzdeflate()/gzinflate() functions as what Leon's suggestion.

Upvotes: 1

Leon Alexis Cardinal
Leon Alexis Cardinal

Reputation: 57

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.

Upvotes: 3

Graham
Graham

Reputation: 667

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.

Upvotes: 7

Matt V.
Matt V.

Reputation: 9809

The Encryption module module includes a basic encryption method by default, which it describes as "A simple mathematical encryption method that does not require any PHP extensions."

Upvotes: 1

Related Questions