Is there some ready-made algorithm to generate invitation code by ruby? I can think at first MD5, but its output is too long for 32, so I want the output length is less than 16.
Thank you in advance.
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.
Assuming you are storing the code (otherwise, what’s the point?) just make a random string, and check to see if it exists before saving, and try a new string if it does. No major algorithm needed.