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...
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With