Jump to content

Search the Community

Showing results for tags 'mcrypt'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. I'm using PHP mcrypt to encrypt data, specifically passwords. The Encryption works fine, I'm guessing. I can encrypt and decrypt data just fine, at least, but I'm having issues storing it in MySQL. Let me post some information. Here is my MySQL structure. CREATE DATABASE db CHARACTER SET utf8 COLLATE utf8_unicode_ci ; use db ; CREATE TABLE IF NOT EXISTS `test` ( `id` int(15) unsigned zerofill NOT NULL AUTO_INCREMENT, `password` char(32) COLLATE utf8_unicode_ci NOT NULL, `password_key` char(128) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; Here is my encryption class. class Encryption { private $_cipher, $_mode, $_hash, $_salt; public function __construct($cipher = MCRYPT_RIJNDAEL_256, $mode = MCRYPT_MODE_ECB, $hash = 'sha512') { $this->_cipher = $cipher; $this->_mode = $mode; $this->_hash = $hash; $this->_salt = 'K~1[G50*?2GV42I.47517Oe67>WOZw=l'; } public function encrypt($data, $key) { $key = hash($this->_hash, $this->_salt . $key . $this->_salt); $key = substr($key, 0, mcrypt_get_key_size($this->_cipher, $this->_mode)); $iv_size = mcrypt_get_iv_size($this->_cipher, $this->_mode); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $crypt = mcrypt_encrypt($this->_cipher, $key, $data, $this->_mode, $iv); return $crypt; } public function decrypt($data, $key) { $key = hash($this->_hash, $this->_salt . $key . $this->_salt); $key = substr($key, 0, mcrypt_get_key_size($this->_cipher, $this->_mode)); $iv_size = mcrypt_get_iv_size($this->_cipher, $this->_mode); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $decrypt = mcrypt_decrypt($this->_cipher, $key, $data, $this->_mode, $iv); return $decrypt; } } I use this to create the key. $key = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true)); My maximum password length is 30 characters, and any password between 8-30 characters always outputs 32 characters. As you can see, my password field is 32 characters. Everything gets put into the database just fine except the password. Using this method I sometimes get crazy looking passwords such as what's in the image attached (I had to attach it because it wouldn't paste properly) Which is fine, in my opinion, but apparently my MySQL table doesn't like this format. I'm guessing utf8_unicode_ci si the wrong format. Anyone have any idea what the correct format is or any other suggestions?
  2. Hey guys, I'm currently using (or trying to use) the php laravel framework. Before I can use this framework I am getting the error: Call to undefined function Laravel\mcrypt_create_iv() I did some research and apparently I don't have the mcrypt extension enabled. I am using php 5.4.7 (AMP Stack) on my mac. I have followed this tutorial and can't seem to get it working at all. http://www.glenscott.co.uk/blog/2011/08/29/install-mcrypt-php-extension-on-mac-os-x-lion/ Anyone else had this issue and manage to resolve it? Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.