p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > PHP/MySQL > Pro PHP
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 22nd, 2009, 02:18 AM
Registered User
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default mcrypt

I am trying to read a flat file and echo each line. The data also contains encrypted passwords which I wish to decyfer. But my script is displaying the following warning:

Code:
Warning: mcrypt_generic_init(): Iv size incorrect; supplied length: 4, needed: 8 in /home/aynsley/public_html/1pw/see_users.php on line 25

dp2 $1$qrBh7zJ8$x5VTTg8qmb1EW7hiXxP9J1 8ϊ
‚
The script

Code:
<?php 

if ($file_array = @file ("./users.txt")) { // Read the file into an array.
    
    // **** Mcrypt *****
    
    // Create a key.
    $mcrypt_key = "Hey! Here's the KEY.1776";
    
    // Open and initialize Mcrypt.
    $mcrypt_module = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_CBC, "");

    foreach ($file_array as $key => $value) { // Loop through each line.
        
        $line = explode ("\t", $value);
        // Decrypt the data.
        $mcrypt_iv = base64_decode (trim($line[3]));
        mcrypt_generic_init ($mcrypt_module, $mcrypt_key, $mcrypt_iv);
        $data = mdecrypt_generic ($mcrypt_module, base64_decode($line[2]));
        
        echo "<pre>$line[0] $line[1] $data</pre><p></p>\n"; // Print the data.
    
    }
    
    // Close Mcrypt.
    mcrypt_generic_end ($mcrypt_module);
    
} else { // If it couldn't read the file, print an error message.
    echo "Could not read the users file!<br />";
}
?>
How do I increase the IV size?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump



All times are GMT -4. The time now is 10:58 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc