Jump to content

Search the Community

Showing results for tags 'aes'.

  • 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. Hi Guys, I need to generate an AES file key (CBC/PKCS7/256bit) using PHP and then obviously need to store the key. The second phase is to encrypt a string using the key generated and stored above, however for the moment its the key generation that is the issue. My first thought was to use OpenSSL as it is a library that can be added to any Apache installation. Any help is greatly appreciated. Cheers in advance.
  2. So I am trying to get this simple encryption to work. I am using AES-CBC. and I know the iv is supposed to be randomly generated each time but for our purposes here it will be fine to keep it as it. Below is the code. It seems to encrypt fine but does not decrypt correctly. <?php $iv='1234567890123456'; $key='9tmp7ifi6n03yAmu'; qrdecrypt(encrypt("test",$key,$iv),$key,$iv); function encrypt($str, $key,$iv) { echo 'in encrypt<br>key:'.$key.'<br>iv:'.$iv.'<br>string:'.$str.'<br>'; $td = mcrypt_module_open("rijndael-128", "", "cbc",$iv); mcrypt_generic_init($td, $key, $iv); $encrypted = mcrypt_generic($td, $str); mcrypt_generic_deinit($td); mcrypt_module_close($td); echo "result is:".bin2hex($encrypted).'<br>returning and calling decrypt...<br>'; return bin2hex($encrypted); } function qrdecrypt($code, $key, $iv) { echo 'in decrypt<br>key:'.$key.'<br>iv:'.$iv.'<br>payload:'.$code.'<br>'; //$code = $this->hex2bin($code); $td = mcrypt_module_open("rijndael-128", "", "cbc", ""); try { mcrypt_generic_init($td, $key, $iv); } catch (Exception $e) { echo $e->getMessage(); } $decrypted = mdecrypt_generic($td, $code); $t=var_export($decrypted,true); echo '<br>Decrypted is:'.$t.'<br>'; mcrypt_generic_deinit($td); echo "deinitted<br>"; mcrypt_module_close($td); echo utf8_encode(trim($decrypted)); } this results in... in encrypt key:9tmp7ifi6n03yAmu iv:1234567890123456 string:test result is:12bc2512b0faea4e6d21368df17f87a6 returning and calling decrypt... in decrypt key:9tmp7ifi6n03yAmu iv:1234567890123456 payload:12bc2512b0faea4e6d21368df17f87a6 Decrypted is:'ro"?�o��h�ȫ_.���̬<�9ptاـ�' deinitted ro"?Ëoð¶hÊÈ«_.ÈÈø̬<ã9ptا٠Any help at all would be appreciated. I am thoroughly stuck at this point.
×
×
  • 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.