Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when use php 7 #26

Open
isarjanfaza opened this issue Nov 25, 2018 · 7 comments
Open

Error when use php 7 #26

isarjanfaza opened this issue Nov 25, 2018 · 7 comments

Comments

@isarjanfaza
Copy link

hi
when use php version 7 not work and get error {main} thrown in MCrypt.php on line 11

please check this bug

thanks

@Goufalite
Copy link

In PHP 7, MCrypt is deprecated... A workaround is to use openssl_* instead :

function encrypt2($str) {
 
			$encrypted = openssl_encrypt($str, 'aes-128-cbc', KEY_SERVICE, OPENSSL_RAW_DATA, IV_SERVICE);
  
			return bin2hex($encrypted);
		  }
  
		  function decrypt2($code) {
			$code = $this->hex2bin($code);
  
			$decrypted = openssl_decrypt($code, 'aes-128-cbc', KEY_SERVICE, OPENSSL_RAW_DATA |  OPENSSL_ZERO_PADDING, IV_SERVICE);
  
			return trim($decrypted);
		  }

@serpro
Copy link
Owner

serpro commented Feb 6, 2019

Thanks @Goufalite for the suggestion.

Would you like to create a pull request to contribute with the code?

@Goufalite
Copy link

I have to check something with the ZERO_PADDING option which messes with the result, then I'll make the pull request

@razmjooDev
Copy link

hi @Goufalite
how to set java class for this code?

@Goufalite
Copy link

Look at the code tab on top, there's a Java MCrypt class.

I still have some leading NULL characters at the beginning so some trim might be in order to process the strings.

@razmjooDev
Copy link

razmjooDev commented Nov 24, 2020

i used that Java class but the results were not the same as your code results

@Goufalite
Copy link

What were the results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants