Decode md5: How can we possibly decode an md5? [closed] - md5

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Is there a chance that we have a similar md5 hashes with a different value when it is converted?
If yes How possible?And have you tried guys to decrypt before an MD5?

Forget md5 for a second. Instead imagine that your hashing function was really dumb and it just added up the value of each byte in the source data.
Now let's say that your source data is just two bytes: 0x01 and 0x02, in that order. For these inputs the hashed value is 3.
Problem is, you can get the same answer of 3 from lots of other byte sequences:
0x01 0x01 0x01
0x00 0x03
0x03
0x02 0x01
...you get the idea, and hopefully you also see that it's impossible to know with any certainty which of those possibilities could have been the original input when all you have is the hashed value, 3.
With md5, the algorithm is far more complex and way better at avoiding collisions, but the principle is the same. It's called a "one-way hash" for this very reason.

A hash is just that: a one-way, condensed value of your input. Many inputs can produce the same output.
Yes, different source data can produce the same hash (a collision).
No, you cannot retrieve the original data from a hash.

If the MD5 is a salted MD5, there is a good chance it'll never be the same as a normal MD5 hash..

Yes, it's possible to produce 1 same hash with different input. This is called collision. Such collision is possible because the input size is greater than the output size. Read about birthday attack to know why is this a bad things in hashing.
here is a article about MD5 has been broken because of the collision.

Related

How to assign a hexadecimal value to an unsigned char variable in a C program [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
The hexadecimal value that I want to store in a variable is of length 32.
"DC4938C31B9E8B30F32FC0F5EC894E16".
I also want to then print this value but I don't know the format specifier in printf for unsigned char.
That's a string of 32 characters, being hexadecimal digits. That makes 16 bytes, or 128 bits.
m0skit0 told you how to store it in a string. If you actually want to store that in an integer, you'd need something like unsigned long long intvar = strtoull( stringvar, NULL, 16 ) - provided "long long" on your machine can stomach 128 bits.
But what you want is something completely different, which became clear only after you linked to that other question. (It's really bad to take something out of context like that, especially if you are confused about what you're actually doing.)
If you take a look at the API documentation, you will see that the parameter you are looking at is a pointer to DES_cblock. That's not a string, and not an integer. Have a look at seed and ivsetup in that other question, how they are initialized, and think for a minute.
That's not a char. It's a string:
unsigned char* value = "DC4938C31B9E8B30F32FC0F5EC894E16";
printf("%s\n", value);
Also, if this is a number I strongly do not suggest you transforming it into a string or char, since strings are slower and prone to more coding errors than numbers.
Numbers represented as hexadecimal (and not hexadecimal numbers, all numbers are hexadecimal, it's just a representation of the value) do not have any characters. Again, it's a number. You can of course convert it to a string (as with any other number) but to do so you should have a strong reason (e.g. the algorithm you want to use is faster with strings than numbers).
I suggest you reading about representation of numbers. A lot of new programmers have problems with this topic.

How long it would take you to make a working code to print out factorial of very very large numbers [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I was given this coding question in interview:
given a very very large number (say more than long or any in-built types) print out its factorial. you can not assume a max limit anywhere in the program.I had to make a working code on computer and during interview.
I am really curious, how long on average would it take for others?
this is subjective question but an average will set some ballpark figures and a benchmarks for such a coding question.
What I did?
I chose C and represented number by a linked list of characters (containing a single digit). though perhaps it can be made more efficient to store chunks in int/long and do int arithmetic than store it in chunk of characters.
I took 2 hours and spat out a code with things in place, major fns coded, but then interviewer said she wanted a completely working one and asked me to do it offline and mail it to her.
The good solution is to write a BigInt class that supports addition and mutilplication only. The number shouldn't be kept in base 10, rather in base 10000, i.e. each digit is a number 0-9999. Writing this is about 50-60 lines of code which should be relatively quick. I would also go with vector rather than list
Of course if you're not allowed to use an existing big int class.
Check the following links
calculate-the-factorial-of-an-arbitrarily-large-number-showing-all-the-digits
http://www.daniweb.com/software-development/cpp/code/216490
calculating-factorial-of-large-numbers-in-c
I'd start by suggesting a straight factorial in Common Lisp as Lisp already supports arbitrary precision arithmetic.
Assuming "no max limits anywhere" is a bit disingenuous since the computer has limited memory / disk space in any case but I understand the general gist.
Barring those two points of argument, you need to implement some sort of ADT for an arbitrary-sized number like Armen suggests.
To what accuracy? My first impulse would be to simply use Stirling's approximation.
There's no way I'm going to implement factorial for longs (bigger than ints) not to say above that.. It's totally pointless. No matter how fast my biginter library is.
32bit -> 4G, product of the numbers just from 1G till 4G.. well, lets just get a quick (under)estimation for the number of digits: 3G * 9 = 27G. rough estimation for the storage for that: 2^10=1024, so for 3 digits you need 1.25 bytes.. that's 11.25G. remember, this was a serious underestimation...

password complexity in C [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Hi I'm on my internship and my company told me that I've to implement password complexity using C language. The password must be Alpha numeric (eg h#ll0). Since I'm new to C , I found some difficulty. I google "password complexity in C " but no luck there. Can someone gave me some sample or explain me how to do it programmatically.
Thanks a lot in advance
Kevin
A better Google term would be "strong password":
http://en.wikipedia.org/wiki/Password_strength
But most of the articles you will find will not be for the C language, and they will probably suggest using a regular expression.
It would probably not be too hard to write your own low-level code to do the check as others have suggested. That would save you the trouble of generating a dependency on some C-language regular expression library to use. However, there is an advantage in using a regular expression because it means that non-C programmers would have a better chance at updating the rule at a later date, and it may make errors less likely to boot. It depends on your particular situation.
(Also, if other parts of your C code need regular expressions, then linking one in might be something you're going to need to do anyway and you'd get it "for free"...)
In any case, this StackOverflow question has a link to a regex.h tutorial, and more may be added to it in the future:
C - pellucid regex.h use tutorial
You don't provide enough information. By password complexity I assume you mean password strength.
I'm not in the business of writing code for someone, but if what you're looking to do is determine whether or not a password contains both a letter and a number, is at least n characters long, etc., C has functions you can do this with. isalnum(), isdigit(), and isalpha() come to mind for testing. These all return nonzero values to indicate true.
In terms of speed, C is fast on its own but remember with these that there is no need to parse the entire password -- all you need is for the function to return a nonzero value at some point. (All of these functions parse by character; C strings are char arrays.)
http://icecube.wisc.edu/~dglo/c_class/charfunc.html This is a good little reference for character parsing functions.
It depends on how the password is encoded, you may need an ASCII character chart or a unicode character chart. For each character in the input password, categorize it into groups number, uppercase letter, lowercase letter or special characters and so on.
here are the links to the tables:
http://www.asciitable.com/
http://www.tamasoft.co.jp/en/general-info/unicode.html

How to generate 8 byte hex value? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I want to generate this sequential data in C:
data_packet[1] = 0706050403020100 (seed_value)
next
data_packet[2] = 0f0e0d0c0b0a0908
Next will be the next 8 hexadecimal characters and so on for say 100 bytes. How can I do it? Can we do it using character array?
You don't want to use a char array since char may or may not be signed (implementation defined). If you are playing with hexadecimal numbers from 0x00 to 0xFF, I strongly recommend using an unsigned char array.
Looks like the values in the array are sequential, from 0 to N. This indicates using a for loop.
The array is a fixed size of 8 bytes. Hmmm, another good candidate for a for loop.
The hard part of your task is the direction of the bytes. For example are filling in the array starting at position 7 or at position 0?
So here is some psuedo code to help you along:
For each value from 0 to N do:
begin
for array position from 0 to 7 do: // or from 7 to 0
put 'value' into the array at 'position';
call function to process the array.
end
For more fun, change the functionality of "put 'value'" to "put random value".
If you want us to actually write your program, let us know. I could use the extra money. :-)

What is a Vector Array? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am suppose to create a vector array in C to use in my project. I have not worked with such data structure before, and can't seem to find good information on it.
Can you provide a link to information or post the information which describes this data structure in regard to its usage, benefits, and the functions it has.
An implementation file would be also useful reference.
"... can't seem to find good information on it." Wat?
Google is pretty much king.
First understand what it is. Then implement based on what you research. You're going to need to understand not only what a vector is, but pointers and structs. Ask your instructor for help, or find a peer to work on this with.
It depends on what you mean by the terms. "Vector" has a very specific mathematical definition, but unfortunately without knowing what you goal is, "vector array" is sort of ambiguous because a vector is an array in a manner of speaking.
If you're doing mathematics in your software, you may actually want an array of vectors as opposed to an array aka vector. But, well, it depends on what you're looking to accomplish. (In my line of work, I need to deal with arrays of vector data, where the vectors are "locations" in 3D space.)
The shortest path would probably be to type:
Vector my_array[4];
...and see if that compiles. If it does not, then an array of Vector objects/structs is not available in your codebase. :)
Look into struct: C/C++ structures and classes.
Simple google search for vector array c
http://www.codecogs.com/d-ox/array/vector.php

Resources