php-openssl

Decrypt AES-256-CFB in PHP with openssl instead mcrypt

独自空忆成欢 提交于 2021-02-08 08:59:25
问题 The function below correctly decrypt the data in php5 function decrypt_mcrypt($key, $str) { $str = base64_decode($str); $iv = substr($str, 0, 16); $str = substr($str, 16); return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_CFB, $iv); } I tried to use openssl instead of mcrypt (in php7), but got garbage on the output. function decrypt_openssl($key, $str) { $str = base64_decode($str); $iv = substr($str, 0, 16); $str = substr($str, 16); return openssl_decrypt($str, 'AES-256-CFB',

SSL/TLS 1.2 Connection Issues - PHP/SQLSRV

笑着哭i 提交于 2021-02-05 08:21:30
问题 I recently disabled TLS 1.0 & TLS 1.1 on a web server, but it seems to have caused some issues with some of the PHP sites I'm running. The error in question is: "[Microsoft][ODBC Driver 11 for SQL Server]Encryption not supported on the client." but I have other sites running on TLS 1.2 on the same server, I even have other PHP-based sites still able to connect to the database despite being earlier versions of PHP (5.3.28, which I think might've even been before TLS 1.2 support was added.. so

PHP Converting mcrypt to openssl

只谈情不闲聊 提交于 2021-02-05 05:25:27
问题 I know 3DES and MD5 are insecure. I will work on replacing them once I have it working again, I have a mobile app that is using 3DES with an MD5 of a key as a SECRET KEY to talk to a PHP Application. Now this code worked perfectly on PHP 5.3 (this is an example I have generated) mcrypt_decrypt( MCRYPT_3DES, md5( utf8_encode( "MobileAppSecureKey" ), true ), base64_decode("bkCfcseIt/TPsgNCdyX9fv2/4MjOJdaPXakNNbxQT3n6tXHa5bDoXojQ3g7jPLCu+wjwD0guQzw3hCFUSVx47PmDNHASk7g/kJ4K4tX0VGI="), MCRYPT_MODE

RSA public key generated in Java is not valid in php

独自空忆成欢 提交于 2021-01-27 23:21:04
问题 I'm creating a RSA key pair in Java and want to use it in PHP. Java code is as follows: public static boolean keyGen() throws NoSuchAlgorithmException, IOException, OperatorCreationException, InvalidKeySpecException { KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA"); kpGen.initialize(2048, new SecureRandom()); KeyPair keyPair = kpGen.generateKeyPair(); PublicKey pub = keyPair.getPublic(); byte[] pubBytes = pub.getEncoded(); SubjectPublicKeyInfo spkInfo = SubjectPublicKeyInfo

From mcrypt_decrypt to openssl_decrypt

白昼怎懂夜的黑 提交于 2021-01-20 11:54:19
问题 I have a question, I want to replace a function call to mcrypt with open_ssl decrypt. but the output is mingled: This is the mcrypt implementation (which works great): $decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, substr(sha1($this->secretKey), 0, 32), base64_decode($encrypted), MCRYPT_MODE_CBC, base64_decode($iv)), "\0..\32"); var_dump($decrypted); And i translated it to: var_dump( trim( openssl_decrypt( $encrypted, 'AES-256-CBC', substr(sha1($this->secretKey), 0, 32), OPENSSL_ZERO

From mcrypt_decrypt to openssl_decrypt

不羁的心 提交于 2021-01-20 11:54:19
问题 I have a question, I want to replace a function call to mcrypt with open_ssl decrypt. but the output is mingled: This is the mcrypt implementation (which works great): $decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, substr(sha1($this->secretKey), 0, 32), base64_decode($encrypted), MCRYPT_MODE_CBC, base64_decode($iv)), "\0..\32"); var_dump($decrypted); And i translated it to: var_dump( trim( openssl_decrypt( $encrypted, 'AES-256-CBC', substr(sha1($this->secretKey), 0, 32), OPENSSL_ZERO

OpenSSL support disabled in Apache/PHP on Windows

亡梦爱人 提交于 2020-07-04 09:53:21
问题 openssl is disabled apache2.4 with php7.1 in phpinfo(); results give me this OpenSSL support disabled (install ext/openssl) i changed this in php.ini extension=php_openssl.dll i use this code using WINDOWS CMD set OPENSSL_CONF=/path/to/openssl.cnf its enabled when use in CMD this but its disabled in phpinfo(); php --ri openssl OpenSSL support => enabled OpenSSL Library Version => OpenSSL 1.0.2j 26 Sep 2016 Openssl default config => C:/jampp/php71/extras/ssl/openssl.cnf its now working in CMD

unable to verify openssl signature in php compare to nodejs

拜拜、爱过 提交于 2020-06-29 03:45:11
问题 I am able to verify the signature by using Nodejs crypto.createVerify whereas PHP: openssl_verify always return false. Nodejs: Getting correct result const encryptKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; const crypto = require('crypto'); var data = Buffer.from(JSON.stringify(vd), "utf-8"); var password = Buffer.from(encryptKey, "utf-8"); var hashPassword = crypto.createHash('sha256').update(password).digest(); var data ='oubWLpvUHAX5Z/9fmiCx8PGTqDl0