php-openssl

Encrypting (large) files in PHP with openSSL

早过忘川 提交于 2019-11-27 07:06:56
问题 I'm trying to encrypt (big) files in PHP using AES and have looked into using Mcrypt and OpenSSL, the problem is all solutions I have found so far only encrypt strings, and the files I'm trying to encrypt would trigger the max memory limit for PHP (which unfortunately can't be set higher), how would I go about achieving this? 回答1: You could use CBC encryption using Mcrypt and then encrypt a segment of data at a time. Make sure that the segment is x times the block size of the used cipher (e.g

php: mcrypt_encrypt to openssl_encrypt, and OPENSSL_ZERO_PADDING problems

[亡魂溺海] 提交于 2019-11-27 05:03:44
I have this mcrypt_encrypt call, for a given $key, $message and $iv: $string = mcrypt_encrypt(MCRYPT_3DES, $key, $message, MCRYPT_MODE_CBC, $iv); I'd like to change the mcrypt_encrypt call to an openssl_encrypt one, to future-proof this. By having $mode = 'des-ede3-cbc' or $mode = '3DES'; and $options = true I get the more similar response, but not identical. Is there other way to call it to get a perfect match? I'm getting this (base64_encoded) for a lorem-ipsum $message + $key combinations, so I'm starting to believe one function or the other are padding somewhat the message before

How to encrypt plaintext with AES-256 CBC in PHP using OpenSSL?

…衆ロ難τιáo~ 提交于 2019-11-27 02:33:11
问题 I am trying to encrypt sensitive user data like personal messages in my php powered website before entering into the database. I have researched a bit on the internet and I have found the few important things to remember: Never use mcrypt, it's abandonware. AES is based on the Rijndael algorithm and has been unbroken till now. AES has also been recommended by NSA and used in US Government data encryption, but since the NSA is recommending it, there's a chance they might sneak upon my user

MCrypt rijndael-128 to OpenSSL aes-128-ecb conversion

别来无恙 提交于 2019-11-27 01:37:58
Since Mcrypt is deprecated, I want to use OpenSSL instead in my code since we already using php 7.0.17 in our server and there's no tell when they upgrade it. Some third party API (hosted on PHP 5.x probably and using mcrypt ), is taking encrypted data. They've provided methods which they are using to encrypt/decrypt strings. Here are they $secret = 'a0a7e7997b6d5fcd55f4b5c32611b87c' ; public function encrypt128($str) { $block = mcrypt_get_block_size("rijndael_128", "ecb"); $pad = $block - (strlen($str) % $block); $str .= str_repeat(chr($pad), $pad); return base64_encode(mcrypt_encrypt(MCRYPT

Supplied key param cannot be coerced into a private key with Google APIs

可紊 提交于 2019-11-26 14:46:27
问题 I'm trying to test this example that I found here so that I can do a direct upload on the client side without having the user login using Google Cloud Storage. All of the constants expressed have their correct values, and the path is correct and does not have an empty contents. The error I'm getting: openssl_sign(): supplied key param cannot be coerced into a private key My function implemented is: public static function storageURL( $id, $method = 'GET', $duration = 10 ) { $key = file_get

php: mcrypt_encrypt to openssl_encrypt, and OPENSSL_ZERO_PADDING problems

本小妞迷上赌 提交于 2019-11-26 12:46:58
问题 I have this mcrypt_encrypt call, for a given $key , $message and $iv : $string = mcrypt_encrypt(MCRYPT_3DES, $key, $message, MCRYPT_MODE_CBC, $iv); I\'d like to change the mcrypt_encrypt call to an openssl_encrypt one, to future-proof this. By having $mode = \'des-ede3-cbc\' or $mode = \'3DES\'; and $options = true I get the more similar response, but not identical. Is there other way to call it to get a perfect match? I\'m getting this (base64_encoded) for a lorem-ipsum $message + $key

Use openssl_encrypt to replace Mcrypt for 3DES-ECB encryption

梦想与她 提交于 2019-11-26 12:33:47
问题 I have an encryption method with mycrypt and the cipher is 3des , mode ecb : mcrypt_module_open ( MCRYPT_3DES, \'\', \'ecb\', \'\' ) Now I want to encrypt it using openssl_encrypt , and I did not find des3-ecb in openssl_get_cipher_methods() list. 回答1: now I want to encrypt it use openssl_encrypt , and I did not find des3-ecb in openssl_get_cipher_methods() list. It's des-ede3 . Symmetric encryption with a block cipher needs some kind of mode of operation. If you look through the list, you

Can't decrypt using pgcrypto from AES-256-CBC but AES-128-CBC is OK

我与影子孤独终老i 提交于 2019-11-26 10:03:06
问题 I have problem decrypting data in pgcrypto that was previously encrypted in PHP app. I tried 3 types of encryption: 1) mcrypt - RIJNDAEL 128 CBC 2) mcrypt - RIJNDAEL 256 CBC 3) openssl_encrypt - aes-256-cbc everything is encrypted decrypted fine in PHP, but in pgcrypto I can decrypt using same key and iv only 1) mcrypt - RIJNDAEL 128 CBC Here is example code for PHP part: <?php function d ($data, $key, $mode) { $data = @base64_decode($data); $pad = $mode == MCRYPT_RIJNDAEL_256 ? 32 : 16; $iv

How to enable PHP&#39;s openssl extension to install Composer?

点点圈 提交于 2019-11-26 09:17:14
问题 I am trying to install Laravel in WAMP setup. I am getting a warning message for not enabling openssl which I had already done in WAMP. Here is a screenshot of the message. 回答1: It is possible that WAMP and Composer are using different PHP installations. Composer will use the PHP set in the PATH environment variable. If you want to enable the openssl extension to install Composer , first you need to check the location of the PHP installation. Open a Command Prompt, type: echo %PATH% then