How do I create unique key value in PHP?
I need simple unique keys with a length of 20 digits (not more than 33).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are looking for an encryption key?
Do not use
uniqid()in any context where security is involved. It is too predictable to be used in such context.The PEAR::Crypt_RSA package allows you to generate cryptographically strong keys in PHP. Once installed in your local PEAR install, you may use it to generate a key as follows:
UUID’s may also be good for your goal. Here is a class which will generate standard-compliant UUIDs on all systems:
Do not use
uniqid()in any context where security is involved. It is too predictable to be used in such context.