Questions tagged [php-openssl]

Using this extension, PHP can use some OpenSSL functions to do direct encryption. This tag should not be used for questions about encrypting traffic(HTTPS)

The OpenSSL extension for PHP uses the functions of (OpenSSL) for generation and verification of signatures and for doing full encryption and decryption of data. This module does not support the full suite of OpenSSL functions, but does offer access to actively maintained encryption libraries as opposed to deprecated libraries like .

For hashing (one-way encryption) check out

405 questions
4
votes
2 answers

openssl_encrypt returning empty string

I am trying to create a UUID on my server, and for some reason openssl_enrypt is initializing an empty string. This would be a different conversation if it was returning false, but it's not, it's returning a string, just one that's empty. Here is…
Adam McGurk
  • 186
  • 1
  • 19
  • 54
4
votes
3 answers

How to decrypt after Mcrypt deprecation?

I have updated my php version to 7.1. I had functions where i encrypt data using mcrypt. Now this function is deprecated. How can i decrypt the data anyway withoud going back to older versions of php. This is the code i used: public function…
Puya Sarmidani
  • 1,226
  • 9
  • 26
4
votes
1 answer

Mock a private/public key in a unit test?

Currently I have a code base that uses openssl_public_encrypt/openssl_private_decrypt. Now I would like to test my encryption and decryption methods with a unit test, since these are pretty vital. To really test them I think I would like to simply…
Stephan-v
  • 19,255
  • 31
  • 115
  • 201
4
votes
1 answer

Equivalent of openssl_public_encrypt PHP function in Ruby

I would like to obtain an equivalent of the code below in ruby: $key = '-----BEGIN PUBLIC KEY----- some public key -----END PUBLIC KEY-----'; $cc_number = '4242424242424242'; openssl_public_encrypt($cc_number, $cc_number_encrypted, $key); echo…
d3m0n
  • 366
  • 1
  • 3
  • 15
4
votes
2 answers

Ssl certificate error: unable to get local issuer certificate on wamp in magento 2

I'm getting SSL certificate problems: unable to get local issuer certificate error when connecting to Magento marketplace using WAMP. Please tell me how to fix it.
Arun Kumar
  • 111
  • 2
  • 3
  • 14
4
votes
2 answers

openssl_encrypt, openssl_decrypt key, iv

According to the documentation of OpenSSL ( https://www.openssl.org/docs/apps/enc.html#OPTIONS ) they expect a hex-digit value for key and iv; does that mean only numbers? or will a md5 hash do? (Because a md5 doesn't seem reversible) Note i'm…
KaekeaSchmear
  • 1,548
  • 5
  • 18
  • 30
4
votes
4 answers

How to verify CA using PHP's OpenSSL extension?

In the command line, I can verify that certificate is issued by trusted CA by typing openssl verify mycert.pem How do I do same with PHP's OpenSSL library? PHP has an openssl_verify function which takes many extra parameters: data , string…
3
votes
1 answer

Why can't I use key lengths < 384bit for EC in PHP OpenSSL?

It is obvious to me that a 384bit RSA Key is tremendously insecure. There is a similar question regarding RSA: Why is keysize < 384 bits deemed too small for openssl_pkey_new()? However, a 384bit EC key is currently seen as extremely secure. In my…
dmuensterer
  • 1,875
  • 11
  • 26
3
votes
0 answers

Openssl giving unpadblock:bad decrypt error

I get this error while trying to decrypt in c++ what I encrypt in php, but it happens only sometimes: B8:48:00:00:error:Provider routines:unpadblock:bad decrypt:providers\implementations\ciphers\ciphercommon_block.c:104: I use php server to…
sepofep298
  • 31
  • 1
3
votes
0 answers

RSA encrypt in JavaScript and decrypt in PHP

I have generated a pair of public and private key using window.crypto.subtle.generateKey. window.crypto.subtle.generateKey( { name: "RSA-OAEP", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash:…
Leon Ma
  • 303
  • 4
  • 13
3
votes
2 answers

Use openssl_decrypt() with passphase (not key/iv)

I'm trying to decrypt some data that has been encrypted with a passphrase and aes-256-cbc method in a PHP script. Here is how I encrypt the original data printf "Hello" | openssl enc -e -base64 -A -aes-256-cbc -k "MYPASSWORD" //…
B 7
  • 670
  • 7
  • 23
3
votes
1 answer

openssl_decrypt for aes-128-cbc not working

I am working on decrypting some content coming from an API. They have provided a command as well. So with some mofication below is the command, which works perfectly fine: openssl enc -d -aes-128-cbc -K 422943374a3568755d7c527f6e472132 -iv…
Hafiz
  • 4,187
  • 12
  • 58
  • 111
3
votes
1 answer

Equivalent to hash_hmac in oppenssl_* functions

What would be an equivalent for: hash_hmac('sha256', 'data', 'key') if I were using openssl_*? openssl_digest does not take $key parameter.
Thor Samsberg
  • 2,219
  • 5
  • 22
  • 30
3
votes
1 answer

How to decrypt data in PHP encrypted with JSEncrypt

I'm trying to secure communication between a JS front-end and a PHP backend by using symmetric and asymmetric encryption. I'm creating a symmetric key on the client and encrypting it with the server's public key with JSEncrypt and sending it to the…
3
votes
1 answer

Error signing pdf with PHP's openssl_pkcs7_sign

I am using TCPDF to generate a pdf document and sign it. TCPDF itself just calls PHP's openssl_pkcs7_sign function, which seems to me to be calling C's PKCS7_sign function based on source code. Until recently things were working fine. Then I changed…
Vic Seedoubleyew
  • 9,888
  • 6
  • 55
  • 76