Given a linux username and a password how can I test if it is a valid account? [closed]

You can validate that a given password is correct for a given username using the shadow file. On most modern distributions, the hashed passwords are stored in the shadow file /etc/shadow (which is only readable by root). As root, pull the line from the shadow file for the given user like so: cat /etc/shadow | … Read more

php: number only hash?

An MD5 or SHA1 hash in PHP returns a hexadecimal number, so all you need to do is convert bases. PHP has a function that can do this for you: $bignum = hexdec( md5(“test”) ); or $bignum = hexdec( sha1(“test”) ); PHP Manual for hexdec Since you want a limited size number, you could then … Read more

What’s the best way to create a short hash, similar to what tiny Url does?

.NET string object has a GetHashCode() function. It returns an integer. Convert it into a hex and then to an 8 characters long string. Like so: string hashCode = String.Format(“{0:X}”, sourceString.GetHashCode()); More on that: http://msdn.microsoft.com/en-us/library/system.string.gethashcode.aspx UPDATE: Added the remarks from the link above to this answer: The behavior of GetHashCode is dependent on its implementation, … Read more

Is there a limit on the message size for SHA-256?

There is technically a limit, but it’s quite large. The padding scheme used for SHA-256 requires that the size of the input (in bits) be expressed as a 64-bit number. Therefore, the maximum size is (264-1)/8 bytes ~= 2’091’752 terabytes. That renders the limit almost entirely theoretical, not practical. Most people don’t have the storage … Read more

Coupon code generation

Basically you can split your operation into to parts: Somehow “encrypt” your initial number n, so that two consecutive numbers yield (very) different results Construct your “human-readable” code from the result of step 1 For step 1 I’d suggest to use a simple block cipher (e.g. a Feistel cipher with a round function of your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)