473,785 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mcrypt_encrypt giving different results for same input?

Hi,

I'm using PHP 4.4.4. An odd thing is happening with the
mcrypt_encrypt function. I am trying to encrypt a string of data (for
password storage):

$enc = mcrypt_encrypt( MCRYPT_XTEA, ENCRYPTION_KEY, $p_str,
MCRYPT_MODE_ECB , $iv);

and then I'm trying to log in later by encrypting the entered password
and comparing it to the saved password. However, despite the fact
that for each call, the inputs are the same,

MCRYPT_XTEA = "xtea";
ENCRYPTION_KEY = "sdlk2kcow8doq9 2k";
$p_str = "demo";
MCRYPT_MODE_ECB = "ecb";
$iv = "jX%ukØ*=";

on one call I get the encrypted string, "ë;jéøÕG·" and on the other
call, I get "ø34Avýä". What gives?

Thanks, - Dave

Oct 1 '07 #1
45 3838
la***********@z ipmail.com wrote:
Hi,

I'm using PHP 4.4.4. An odd thing is happening with the
mcrypt_encrypt function. I am trying to encrypt a string of data (for
password storage):

$enc = mcrypt_encrypt( MCRYPT_XTEA, ENCRYPTION_KEY, $p_str,
MCRYPT_MODE_ECB , $iv);

and then I'm trying to log in later by encrypting the entered password
and comparing it to the saved password. However, despite the fact
that for each call, the inputs are the same,

MCRYPT_XTEA = "xtea";
ENCRYPTION_KEY = "sdlk2kcow8doq9 2k";
$p_str = "demo";
MCRYPT_MODE_ECB = "ecb";
$iv = "jX%ukØ*=";

on one call I get the encrypted string, "ë;jéøÕG·" and on the other
call, I get "ø34Avýä". What gives?

Thanks, - Dave
Dave,

I hate to state the obvious, but obviously there is something different
between the two. mcrypt_encrypt gives the same output for the same input.

Look for differences in capitalization, '1' (one) instead of 'l' (lower
case ell) or 'I' (upper case eye), for instance. It's very easy to do.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Oct 2 '07 #2
Mtr
well, not necesarily. Maybe it's a chain cypher - and he's not
re-initializing.

Although his code sample does say ECB, I don't know what the parameters
mean for this extension function anyway.

On Mon, 01 Oct 2007 23:20:14 -0400, Jerry Stuckle <js*******@attg lobal.net>
wrote:
>la***********@ zipmail.com wrote:
>>
on one call I get the encrypted string, "ë;jéøÕG·" and on the other
call, I get "ø34Avýä". What gives?

Thanks, - Dave
>I hate to state the obvious, but obviously there is something different
between the two. mcrypt_encrypt gives the same output for the same input.

Look for differences in capitalization, '1' (one) instead of 'l' (lower
case ell) or 'I' (upper case eye), for instance. It's very easy to do.
Oct 2 '07 #3
Mtr wrote:
On Mon, 01 Oct 2007 23:20:14 -0400, Jerry Stuckle <js*******@attg lobal.net>
wrote:
>la***********@z ipmail.com wrote:
>>on one call I get the encrypted string, "ë;jéøÕG·" and on the other
call, I get "ø34Avýä". What gives?

Thanks, - Dave
>I hate to state the obvious, but obviously there is something different
between the two. mcrypt_encrypt gives the same output for the same input.

Look for differences in capitalization, '1' (one) instead of 'l' (lower
case ell) or 'I' (upper case eye), for instance. It's very easy to do.

well, not necesarily. Maybe it's a chain cypher - and he's not
re-initializing.

Although his code sample does say ECB, I don't know what the parameters
mean for this extension function anyway.
(top posting fixed)

Your posting makes no sense whatsoever. Did you actually try the code?

If it were a chain cipher, you would have to follow the same chain to
decrypt. And a quick test of the code would have shown you this is not
a chain cipher.

Also, please don't top post. Thanks.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Oct 2 '07 #4
Mtr
not to be overly contentious, but it is pretentious to insist on bottom
posting. All you are saying is that you want people to post in a way that
is better for you, in the way that you read newsgroups. But if I read a
thread all at once (since I am apt to read a group maybe once a week or so)
then bottom posting is a burden because of all the needless scrolling. If I
read only one newsgroup per day, then all that downward scrolling is an
unnecesary burden, too. I don't need to be refreshed on the topic because
I'm not reading many groups every day. Also, anyone reading a thread on
google groups would find the same thing - endless scrolling past old words
to get to the new words.

If you are trying to make the newsgroup more readable, then you would be
better off trying to get people to trim their replies. Your post in the
Lite Encryption thread is a good example of what not to do: over two
hundred lines of quoting to add a very few lines of new reply.

However, I appreciate your politeness.
On Tue, 02 Oct 2007 06:58:58 -0400, Jerry Stuckle <js*******@attg lobal.net>
wrote:
>
Also, please don't top post. Thanks.
Oct 2 '07 #5
..oO(Mtr)
>not to be overly contentious, but it is pretentious to insist on bottom
posting. All you are saying is that you want people to post in a way that
is better for you, in the way that you read newsgroups.
It's not only for him. It's the way that's better for _most_ regulars in
the newsgroups.
>But if I read a
thread all at once (since I am apt to read a group maybe once a week or so)
then bottom posting is a burden because of all the needless scrolling.
Of course quoting two hundred lines and then just adding a "me too" is
pointless. But quoting a question or statement and then putting an
answer below it is the most efficient way, especially if you're replying
to many different parts or questions of a post.
>If I
read only one newsgroup per day, then all that downward scrolling is an
unnecesary burden, too. I don't need to be refreshed on the topic because
I'm not reading many groups every day. Also, anyone reading a thread on
google groups would find the same thing - endless scrolling past old words
to get to the new words.
Google Groups just sucks. That's not Usenet.
>If you are trying to make the newsgroup more readable, then you would be
better off trying to get people to trim their replies.
ACK

That's as important as putting an answer _below_ the question.

Micha
Oct 2 '07 #6
Mtr
On Tue, 02 Oct 2007 06:58:58 -0400, Jerry Stuckle <js*******@attg lobal.net>
wrote:
>Mtr wrote:
>On Mon, 01 Oct 2007 23:20:14 -0400, Jerry Stuckle <js*******@attg lobal.net>
wrote:
>>la***********@z ipmail.com wrote:
>>>on one call I get the encrypted string, "ë;jéøÕG·" and on the other
call, I get "ø34Avýä". What gives?

Thanks, - Dave
>>I hate to state the obvious, but obviously there is something different
between the two. mcrypt_encrypt gives the same output for the same input.

Look for differences in capitalization, '1' (one) instead of 'l' (lower
case ell) or 'I' (upper case eye), for instance. It's very easy to do.

well, not necesarily. Maybe it's a chain cypher - and he's not
re-initializing.

Although his code sample does say ECB, I don't know what the parameters
mean for this extension function anyway.

(top posting fixed)

Your posting makes no sense whatsoever. Did you actually try the code?
no, that's why I deliberately used the word "maybe" in my suggestion. No
one else had replied, so I offered a possible suggestion.
>
If it were a chain cipher, you would have to follow the same chain to
decrypt.
He never mentioned decryption in his post, only the diffrent results of
encryption.
>And a quick test of the code would have shown you this is not
a chain cipher.
no, now you're the one who is making no sense. Whether or not it is chained
is internal to the cipher, not to the code that calls it. The difference
would also be apparent (via knowledge of the parameters) if I were a user
of that crypto extension, which I'm not. That's why I also deliberately
said that I don't know what the parameters mean. But the use of ECB does
tend to say it's not chained - which I also deliberately mentioned.
>
Also, please don't top post. Thanks.
do you know that some people get irritated over interleaved replies, too?
Oct 2 '07 #7
Mtr
On Tue, 02 Oct 2007 16:56:36 +0200, "Rik Wasmus"
<lu************ @hotmail.comwro te:
>
It is quite arrogant to insist to know better then a usenet practise that
has evolved en been followed for years and years.
and once upon a time, people rode horses. Saying "it was always done that
way" is not a valid argument. Once upon a time, people were told to lurk
for days or weeks to get aquainted before making a first post. Or people
were routinely told to RTFM.
>Contrary to online
forums, usenet is not on a single server, but thousands of them. Wether or
not other people seeing your reply to a group can see the original message
you are replying to is not something you can rely on.
which is irrelevant as to whether top or bottom posting should be used.
Once again, you are merely claiming that things should be *your* way.
Oct 2 '07 #8
..oO(Mtr)
>On Tue, 02 Oct 2007 06:58:58 -0400, Jerry Stuckle <js*******@attg lobal.net>
>>
Also, please don't top post. Thanks.

do you know that some people get irritated over interleaved replies, too?
Only Usenet newbies, if any. But most people are able to learn.

Micha
Oct 2 '07 #9
--
Rik Wasmus

It is not *my* way. It's the general concensus sparing a few individuals
who are arrogant anough to claim to know better.
Once again, you are merely claiming that things should be *your* way.
Have you ever tried to read of bottom-up conversation when you have no
previous posts? It's not that easy to follow, at least not that quickly.
Scrolling to the new parts of a post (which many newsreaders do
automagically) however is simple. BTW: claiming something is kludgy in
Google Groups isn't an argument either. Complain to the people making that
horrendous interface.
which is irrelevant as to whether top or bottom posting should be used.
>Contrary to online
forums, usenet is not on a single server, but thousands of them. Wether
or
not other people seeing your reply to a group can see the original
message
you are replying to is not something you can rely on.
I still often reply with just an url of the manual.
Or people
were routinely told to RTFM.
What exactly has been changed about usenet in the mean time? By all means,
you're welcome to piss off, and just use online forums as your usenet <->
internet forums, horse <-car equivalent. The practise of riding horses
(posting on usenet) hasn't changed, except for an eternal september.
and once upon a time, people rode horses. Saying "it was always done that
way" is not a valid argument.
>It is quite arrogant to insist to know better then a usenet practise
that
has evolved en been followed for years and years.
On Tue, 02 Oct 2007 16:56:36 +0200, "Rik Wasmus"
<lu************ @hotmail.comwro te:
On Tue, 02 Oct 2007 17:06:37 +0200, Mtr <Mt*@no.spamwro te:

Ok, let's start with an example:
Oct 2 '07 #10

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

Similar topics

2
1521
by: ungvichian | last post by:
Okay, how do I write a page with a form so that when I click Submit, the following happens? 1. The data is submitted (of course) 2. The form is cleared (what I've tried results in the form being cleared first, resulting in an empty submission), and 3. The cursor goes back to the start of the form, ready for more input (kind of like how Google puts the cursor in the search box at the start).
1
1772
by: RM | last post by:
I am using DataSet's .ReadXml() method to parse an XML file that has an inline schema and Im getting "different" results on various machines using the same myDataSet.ReadXml("myExample.xml"). Out of 5 test machines, my results are as follows. 1 Windows 2000 Server and 2 Windows XP Professional PC's that parses the XML, builds 2 tables with appropriate format columns (string, int, etc) and populates the tables with rows of data as...
13
1443
by: Raja Kiran Kumar Reddy Sandireddy | last post by:
Hi, I observed a very strange phenomenon with my program outputs. I run my C-program on MSDOS environment and the same program on Sun-session. I get same output when the input is a small file (which has details for a circuit with, say, less than 30 logic gates). But, the same program processes the inputs differently in these environment and give different results when the input file describes a larger circuit (say, more than 100...
2
5260
by: Sridhar | last post by:
Hi, I have a web form where it has a <input type=file id=file1> control. I have an Upload button to upload the file. WHen I click on browse and select one file, it is showing the full file path in the text box of File control. But in the code behind when I try to get the FullFile path using file1.PostedFile.FilePath it is not giving the full path (c:\test\test.pdf). Instead it is giving only file name (test.pdf). If i try to do this on...
3
3399
by: Shawn T | last post by:
I have an application with a page that has a web user control When I call that page that has this user control, locally (http:// localhost/ApplicationX/default.aspx) and also externally ie (http:// <webserver>/ApplicationX/default.aspx), the display is all different. For example, a text box shows with border on one and textbox shows as label in the other. I am suspecting that it might be CSS issue. I checked the CSS file and everything...
7
4617
bugboy
by: bugboy | last post by:
Hi, I'm just learning PHP. I want to redirect the user, after hitting submit, either to the same page displaying the results (as it is now) or if no results are found then send them to a new page passing on the original form data there instead. Below is a simplified version of what i'm trying to do. The user sumits a word. If it's in the DB then the word is listed below the reset form. What i need is to redirect to a new page "newword.php" if...
3
3653
by: haelly | last post by:
Write a program that prompts the user to enter three different integer values.If the values are not different, the program prints a message"equal values" and terminates(hint: use the return statement).If either of the values is negative,the progra prints"Negative input" and terminates.Otherwie, it prints the values that the user enters. After that, the program compares the first integer and the second ineger and prints either "The first integer...
10
1236
by: Geoff Cox | last post by:
Hello, Can anyone tell me why these 2 sets of code give different results? for (J in Next) { <action> } <function>
87
3754
by: pereges | last post by:
I have a C program which I created on Windows machine. I have compiled and executed the program on windows machine and it gives me the consistent output every time i run it. for eg. input a = 2, b =3 lets say a sum operation is to be performed, then: output: 5
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
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 we have to send another system
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.