473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

mcrypt_enc_get_iv_size not working

mcrypt_enc_get_iv_size is not randomizing the vector. I have tried to
randomize the seed in various ways but it always returns the same output.

My current code as follows:

for($i = 1; $i < 5; $i++)
{
list($usec, $sec) = explode(' ', microtime());
srand((float) $sec + ((float) $usec * 100000));

$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->CryptRes),
MCRYPT_RAND);
echo $iv."<br/>\n";
}

It outputs the same string each time.
Any ideas?

Thanks,
Jon
May 31 '07 #1
3 2284
Of course I meant mcrypt_create_iv...
May 31 '07 #2
C.
On 31 May, 19:27, "Jon Slaughter" <Jon_Slaugh...@Hotmail.comwrote:
Of course I meant mcrypt_create_iv...
Code looks OK.

Are you getting a sensible value for mcrypt_enc_get_iv_size($this-
>CryptRes) ?
Have you tried using the devices as an entropy source?

IIRC mcrypt uses binary strings, in some cases it even assigns C
strings to PHP strings; it might be a better idea to encode the output
before writing to the console/browser:

echo base64_encode($iv) ."<br/>\n";

C.

May 31 '07 #3

"C." <co************@gmail.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
On 31 May, 19:27, "Jon Slaughter" <Jon_Slaugh...@Hotmail.comwrote:
>Of course I meant mcrypt_create_iv...

Code looks OK.

Are you getting a sensible value for mcrypt_enc_get_iv_size($this-
>>CryptRes) ?
yeah, its a bug in mcrypt and I randomized the string it returned myself.
Have you tried using the devices as an entropy source?

IIRC mcrypt uses binary strings, in some cases it even assigns C
strings to PHP strings; it might be a better idea to encode the output
before writing to the console/browser:

echo base64_encode($iv) ."<br/>\n";
Well, it was just for a test.. in reality there is no writing to the
console. Was just trying to figure why my strings were not being randomized.

Thanks,
Jon
May 31 '07 #4

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

Similar topics

2
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the...
6
by: Mullin Yu | last post by:
hi, i have a web service that has file operations on Windows OS, and there may be a file concurrency issue if only one working directory e.g. c:\working therefore, i want to have a unique sub...
3
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my...
8
by: Hardy Wang | last post by:
Hi: Is it possible for me to create/open web application from remote machine other than port 80? And create application directly under virtual web site instead of creating a virtual directory?...
5
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We...
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
8
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs...
2
by: Don | last post by:
I'm having problems with intellisense, autocomplete, etc. suddenly not working in certain classes of a project I'm working on. All the options are set, and it all works fine for most classes, but...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.