webdevRefinery Forum: Asymmetric encryption in PHP - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is offline Sole_Wolf 

  • Group: Members
  • Posts: 302
  • Joined: 24-March 10
  • Expertise:HTML,PHP,Java,SQL

Posted 20 August 2012 - 09:37 PM (#1)

Asymmetric encryption in PHP


Are there any asymmetric encryptions available in PHP that are installed by default?

I tried the mcrypt_encrypt function but I received an error message saying that the function was undefined.

Are there any simple functions like md5 that are asymmetric encryptions?
--Sole_Wolf
0


User is offline Daniel15 

  • dan.cx
  • Group: Moderators
  • Posts: 3415
  • Joined: 17-April 10
  • LocationMelbourne, Australia
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 20 August 2012 - 10:23 PM (#2)

mcrypt is symmetric, not asymmetric. For asymmetric encryption you probably want the OpenSSL extension and use openssl_public_encrypt and openssl_private_decrypt (or vice versa)

Here's an example: http://andytson.com/...-using-openssl/

I don't think there's an 'inbuilt' way to do this. Just use the extension, and don't reinvent the wheel. OpenSSL does a very good job of this :)
Daniel15! :D
Posted Image

Repeat after me: jQuery is not JavaScript. It is not the answer to every JavaScript-related question. When you have to write some JavaScript, do not instantly react with "Oh, I'll do that with jQuery!"

Spoiler
0


User is offline Sole_Wolf 

  • Group: Members
  • Posts: 302
  • Joined: 24-March 10
  • Expertise:HTML,PHP,Java,SQL

Posted 21 August 2012 - 09:21 PM (#3)

View PostDaniel15, on 20 August 2012 - 10:23 PM, said:

mcrypt is symmetric, not asymmetric. For asymmetric encryption you probably want the OpenSSL extension and use openssl_public_encrypt and openssl_private_decrypt (or vice versa)

Here's an example: http://andytson.com/...-using-openssl/

I don't think there's an 'inbuilt' way to do this. Just use the extension, and don't reinvent the wheel. OpenSSL does a very good job of this :)

Well the reason why I ask is because I want my script to run on multiple machines. I'm afraid that some machines won't have the extension compiled with PHP by default which would end up breaking my script.

Are extensions the only way to get an asymmetric type encryption or is there some other function that everyone could have support for by default?
--Sole_Wolf
0


User is offline Daniel15 

  • dan.cx
  • Group: Moderators
  • Posts: 3415
  • Joined: 17-April 10
  • LocationMelbourne, Australia
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 21 August 2012 - 10:49 PM (#4)

I'd trust an extension over any "pure PHP" code implementing asymmetric encryption algorithms. The OpenSSL library is tried and tested.

If it's a script you'll be distributing, just write "This script requires the OpenSSL extension to be installed" in its README file :P
Daniel15! :D
Posted Image

Repeat after me: jQuery is not JavaScript. It is not the answer to every JavaScript-related question. When you have to write some JavaScript, do not instantly react with "Oh, I'll do that with jQuery!"

Spoiler
0


User is offline Sole_Wolf 

  • Group: Members
  • Posts: 302
  • Joined: 24-March 10
  • Expertise:HTML,PHP,Java,SQL

Posted 23 August 2012 - 07:11 PM (#5)

View PostDaniel15, on 21 August 2012 - 10:49 PM, said:

I'd trust an extension over any "pure PHP" code implementing asymmetric encryption algorithms. The OpenSSL library is tried and tested.

If it's a script you'll be distributing, just write "This script requires the OpenSSL extension to be installed" in its README file :P

Gah, oh well lol. I guess that'll have to do. Thanks for your help.
--Sole_Wolf
0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services