Md5 mix with upper and lowercase [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can I generate md5 string with upper and lowercase letter?
for example: TyUTExUM3Dw
What I’ve tried
$id = $_GET['id'];
$key = "SecreTkEy";
$hash = md5($id.$key);
echo $hash;

The string "TyUTExUM3Dw" is not an MD5 hash, nor anything close to one.
An MD5 hash is a number, and is usually written in hexadecimal which uses 16 digits represented by 0-9 and A-F.
Casing is not important.
The hashes b529d8871187ecc7fe5f152142b3440a and B529D8871187ECC7FE5F152142B3440A are exactly the same.
What is the end goal you're trying to accomplish with your code? If you tell us that we can probably give you a better method to accomplish that.

Related

Formatting a string in PHP? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm going through sprintf() and other string formatting functions, but I have been unable to find an exact solution for stripping certain types of characters from a string. I wrote a function for this purpose (which seems quite nasty and not at all worth sharing here) but I am sure there is a easier way for what I am looking for.
$var = "abc244$%!";
now I want to format it this way:
$alpha = some_function($var); // alphabets only
$num = some_function($var); // numbers only
$alpha2 = some_function($var); // alphabets and special characters, no numbers.
To strip everything except numbers, use this:
$allnums=preg_replace("/[^0-9]/","",$var);
For all letters:
$letters=preg_replace('/\PL/u', "", $var);
For special chars:
$specialchars=preg_replace("/[a-zA-Z0-9]/", "", $var);

Compare 2 strings PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Helllo, I wonder if there is a way to compare two strings and get the number of different letters (or any other metrics of difference). strcmp() doesn't really work, since it return some random numbers, which I can't use. My goal is to compare two strings and find if they are different in more than 5 symbols. Can someone give me a hint. Thank you for your time.
Sounds like one of the rare occasions where levenshtein() can be used.
The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform str1 into str2.
You could try using PHP's similar_text function:
$matching_char_count = similar_text($var_1, $var_2, $percent);
echo $matching_char_count;
echo $percent;

MD5 with double randomized salt? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm coding a CMS, but does this work?
MD5(MD5(username+password)+salt+rsalt);
The rsalt stands for Randomized salt but how can i randomize a salt anyway?
You can randomize the salt if you are storing said salt in the user's table. Otherwise, how will you be able to tell if the hash is correct?
MD5 is not a secure hash function. You should use something like password_hash if you have PHP >= 5.5 or the password_compat library by ircmaxell if you're using an earlier version.

PHP Individual Character validation. Regex? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Not terribly familiar with regex, but I'm guessing it's going to make life much easier for my current need.
I need to validate that a string contains the correct sequence of numbers and letters, so that it always follows the format "AA99999A", where A can be any A-Z character and 9 can be any 0-9 character. Other than exploding the string and validating the characters individually, how would the best way to handle this be?
The result can be a simple true / false as I don't need to specify which characters are incorrect
How about:
preg_match('/^[A-Z]{2}\d{5}[A-Z]$/', $string);
You can try this regex:
'/^[A-Z]{2}\d{5}[A-Z]$/i'
PHP's preg_match will do the trick:
$string_to_be_validated = "AB12345C";
if (preg_match("/\A[A-Z]{2}[0-9]{5}[A-Z]{1}\z/", $string_to_be_validated)) echo "valid";
else echo "invalid";
Here you can find more information on this.

Regular expression for password verification [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have been handed a task of putting together a login screen. I found something workable online but I'm having a problem writing the regular expression to validate the password. The following policy should be enforced -- the password should be exactly 14 characters long and should include:
At least 2 upper case letters,
at least 2 lower case letters,
at least 2 numbers, and
at least 2 'special' characters
I have no idea how to write this. Can anybody help?
Assuming by "special characters" you mean anything that isn't a letter or number:
^(?=.*[a-z].*[a-z])(?=.*[A-Z].*[A-Z])(?=.*[0-9].*[0-9])(?=.*[^A-Za-z0-9].*[^A-Za-z0-9]).{14}$

Categories