473,472 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Troubling warnings using PHP decrypt functions

Hi,

I'm using PHP 4.4.4. Using code from this newsgroup, I have a decrypt
function, trying to decrypt data (encryped using a corresponding mcrypt
function). What am I doing wrong? These are the warnings, generated
from the decrypt function (lines are marked in the function, code
follows)

Warning: pack() [function.pack]: Type H: not enough characters in
string in /usr/local/apache2/htdocs/refillingstation/form_fns.php on
line 173

Warning: mcrypt_generic_init(): Iv size incorrect; supplied length: 4,
needed: 16 in /usr/local/apache2/htdocs/refillingstation/form_fns.php
on line 180

Any guidance is greatly appreciated to eliminate these warnings.

function decryptData( $input ) {
$iv = substr ( $input, 0, 32 );
$iv = pack ( H32, $iv ); // line 173

$input = substr ( $input, 32, strlen ( $input ) );
$input =pack("H" . strlen ( $input ) , $input );

$td = mcrypt_module_open('rijndael-128', '', 'cbc',
'');

mcrypt_generic_init($td, ENCRYPTION_KEY, $iv);
// line 180

$dec = mdecrypt_generic($td, $input );

mcrypt_generic_deinit($td);
mcrypt_module_close($td);

return trim ( $dec );
}

function encryptData($input) {

$td = mcrypt_module_open('rijndael-128', '', 'cbc',
'');

// iv = initiailization_vector;

$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td),
MCRYPT_RAND );

mcrypt_generic_init($td, ENCRYPTION_KEY, $iv);

$encrypted_data = mcrypt_generic($td, $input);

mcrypt_generic_deinit($td);
mcrypt_module_close($td);

$encrypted_data = bin2hex ( $iv ) . bin2hex (
$encrypted_data );

return $encrypted_data;

} // end function

Sep 28 '06 #1
0 1156

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ross Marrins | last post by:
Hi, Anyone know how to disable non-fatal PHP warnings from appearing in the browser when the PHP file is run? My code is ok I think, the results are as expected, but im getting warnings...
4
by: Spikinsson | last post by:
I'm looking for a good decrypt/encrypt function, all I want is a function in this form: char* encrypt(char* normal) { ... return encrypted; } and
22
by: John Fisher | last post by:
void f(int p) { } Many (most?) compilers will report that p is unreferenced here. This may not be a problem as f may have to match some common prototype. Typically pointers to functions are...
12
by: Charlie | last post by:
Hi: My host will not allow me use a trusted connection or make registry setting, so I'm stuck trying find a way to hide connection string which will be stored in web.config file. If I encrypt...
0
by: Kelvin | last post by:
Dear all, I don't know how to write a asp/vb/c# program to decrypt PHP encrypted code. Here is attched my code in PHP $key = "ab"; $random_number = kelvin;...
5
by: livefreeordie | last post by:
Hi, I'm part of a 5-person team that develops websites for our company. I need to use the ftp_* functions to find some files on another file server. I need to authenticate to the file server...
2
by: Bernard Dhooghe | last post by:
The information center writes: "Encryption Algorithm: The internal encryption algorithm used is RC2 block cipher with padding, the 128-bit secret key is derived from the password using a MD2...
2
by: =?Utf-8?B?RGF2aWQ=?= | last post by:
Hello, I am getting several warnings associated with direct x h files. I'll post one of them as an example: 1>C:\Program Files\Microsoft DirectX SDK (February 2007)\Include\strsafe.h(5595) :...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.