mcrypt

How to check if mcrypt extension exists in php

人盡茶涼 提交于 2019-12-05 13:39:10
问题 I would like to know the simplest and fastest PHP code line to check if mcrypt extension is available/installed. There is a function that encrypts a string and first it requires to check if mcrypt is usable. If not, it will execute an alternative encrypt solution available on the system. Thanks! 回答1: You can use function_exists to check if one of the mcrypt functions exists. if(function_exists('mcrypt_encrypt')) { echo "mcrypt is loaded!"; } else { echo "mcrypt isn't loaded!"; } Edit 30.07

problem with mcrypt installation

大憨熊 提交于 2019-12-05 12:38:42
问题 I've asked the system admins to install mcrypt on the server, and they say everything is OK. But when I run my simple script I get this. Warning: mcrypt_get_iv_size() [function.mcrypt-get-iv-size]: Module initialization failed It's coming from this line: $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB); Now, from this code: $algorithms = mcrypt_list_algorithms("/usr/local/bin/mcrypt"); foreach ($algorithms as $cipher) { echo "$cipher<br />\n"; } I get: Warning: mcrypt_list

Decrypting mcrypt encoded text with node.js

被刻印的时光 ゝ 提交于 2019-12-05 12:27:09
I have text encoded with Blowfish using PHP's mcrypt: $td = mcrypt_module_open ('blowfish', '', 'cfb', ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); mcrypt_generic_init ($td, "somekey", $iv); $crypttext = mcrypt_generic ($td, "sometext"); mcrypt_generic_deinit ($td); $res = base64_encode($iv.$crypttext); When trying to decode the data with Node's crypto library I get garbage output. var crypto = require("crypto"), ivAndCiphertext = "base64-encoded-ciphertext", iv, cipherText, ivSize = 8, res= ""; ivAndCiphertext = new Buffer(ivAndCiphertext, 'base64'); iv = new

.Net and PHP Rijndael encryption not matching

梦想与她 提交于 2019-12-05 11:47:57
At first i thought it was the padding since mcrypt uses zero padding but i changed the php to use PKCS7 and get the same exact results Can anyone help? I think it has something to do with the padding in the php Test output from .Net: Key: d88f92e4fa27f6d45b49446c7fc76976 Text: Testing123 Encrypted: /DMkj7BL9Eu2LMxKhdGT+A== Encrypted after base64 decode: ?3$??K?K?,?J??? Decrypted: Testing123 Test output from PHP: Key: d88f92e4fa27f6d45b49446c7fc76976 Text: Testing123 Encrypted: K+ke5FNI5T6F6B/XvDF494+S8538Ze83cFz6v1FE89U= Encrypted after base64 decode: +éäSHå>…è×¼1x÷’óüeï7p\ú¿QDóÕ Decrypted:

How can I mcrypt 128 CFB to Ruby?

↘锁芯ラ 提交于 2019-12-05 10:56:21
I need to exchange with a PHP API which crypts the requests and answers. On my side I am in rails 4.0.0 (ruby 2.0) and I cannot make it work. I have read a lot of answers on this subject and have tried to understand how mcrypt works, e.g. http://www.chilkatsoft.com/p/php_aes.asp , but without success. I still cannot decrypt the encrypted from PHP or encrypt something that the PHP can decrypt Could you help me please and see what I am doing wrong? PHP code: $secretKey = "1234567891234567"; $encrypt = urlencode( base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_128, md5($secretKey), $cleartext,

mcrypt_encrypt not working properly on PHP 5.6.9

一世执手 提交于 2019-12-05 08:24:04
I have the following code which worked fine on PHP 5.5.9. function index() { echo $this->encryptText_3des('TEST','JHHKJH9879'); } function encryptText_3des($plainText, $key) { $key = hash("md5", $key, TRUE); for ($x=0;$x<8;$x++) { $key = $key.substr($key, $x, 1); } $padded = $this->pkcs5_pad($plainText, mcrypt_get_block_size(MCRYPT_3DES, MCRYPT_MODE_CBC)); $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_3DES, $key, $padded, MCRYPT_MODE_CBC)); return $encrypted; } function pkcs5_pad ($text, $blocksize) { $pad = $blocksize - (strlen($text) % $blocksize); return $text . str_repeat(chr($pad),

Why does something encrypted in PHP not match the same string encrypted in Ruby?

若如初见. 提交于 2019-12-05 06:10:12
Here are my requirements: I need to encrypt a string in PHP using AES encryption (including a random iv), Base64 encode it, then URL-encode it so that it can be passed as a URL parameter. I am trying to get the same result in both PHP and Ruby, but I can't make it work. Here is my PHP code: function encryptData($data,$iv){ $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $iv_size = mcrypt_enc_get_iv_size($cipher); if (mcrypt_generic_init($cipher, 'g6zys8dlvvut6b1omxc5w15gnfad3jhb', $iv) != -1){ $cipherText = mcrypt_generic($cipher,$data ); mcrypt_generic_deinit(

Data corruption: Where's the bug‽

匆匆过客 提交于 2019-12-05 04:50:28
Last edit: I've figured out what the problem was (see my own answer below) but I cannot mark the question as answered, it would seem. If someone can answer the questions I have in my answer below, namely, is this a bug in Cython or is this Cython's intended behavior, I will mark that answer as accepted, because that would be the most useful lesson to gain from this, IMHO. Firstly, I have to start by saying that I have been trying to figure this out for three days, and I am just banging my head against the wall. As best as I can tell from the documentation, I am doing things correctly.

PHP crypt and salt - more clarification please

拥有回忆 提交于 2019-12-05 02:52:56
I was here yesterday and got some really great answers. I took what I got and put together, what I think will be a fairly secure algorithm. I'm having a problem using blowfish with a for loop that generates the salt. I'm using base64 characters and a for loop to get a random string. I want to take this generated string and insert it into the crypt function as the salt. Because the documentation about blowfish is so sparse and the PHP docs don't really even mention it, I'm sort of stabbing in the dark here. The really strange thing is if you run this code the way it is now, it will not fail.

Mcrypt PHP extension required in Laravel [duplicate]

落花浮王杯 提交于 2019-12-05 02:29:34
问题 This question already has answers here : Laravel requires the Mcrypt PHP extension (22 answers) Closed 2 years ago . I'm trying to install Laravel on Linux Ubuntu. I'm running Ubuntu 14.10. Everything worked alright. But now instead of getting the supposed page when accessing localhost I get the message: " Mcrypt PHP extension required " I'm copying some information from terminal to help pinpoint the problem. which php /usr/bin/php php --ini Configuration File (php.ini) Path: /etc/php5/cli