Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCarl Amess
Courses Plus Student 2,527 PointsCreating Unique Alpha Numeric Codes
I am very new to programming and have recently been learning Javascript.
I have a project that I would like to complete that involves the following:-
1) Generating a set number of unique Alpha numeric codes (these will be done in various batch sizes from 10 - 3000), they must also be unique.
2) convert the Code to a QR Code to be appended to a PDF (for later photographing)
3) A school photo shoot will be carried out using the QR Code where each child is photographed with one code.
4) Images are then processed by the webiste and will take the QR Code Alpha numeric and tag it to the image.
5) The images will then be uploaded to a separate website and the original Alpha numeric will be used by the parent to view just their childs images.
So the Question........
What is the best way to ensure that the Alpha Numeric remains unique across all possible combinations?
1) Should I create a text file on the server that holds each previously created code to be checked each time a new one is created.
2) Put the previously assigned codes in a back end database to be checked each time.
3) Some other method that I need to research...?
It is important that each child's image has a unique password otherwise parents would potentially view children that are not their own if a code is ever duplicated.
And for information the reason that I am using Javascript is that eventually I would like to build in the functionality of having my own developed Online viewing website for the images.
Thank you in advance for helping.
Regards
1 Answer
Zimri Leijen
11,835 PointsFor number 1, you can use UUID
for number 2, maybe this one: https://www.npmjs.com/package/qrcode
Carl Amess
Courses Plus Student 2,527 PointsCarl Amess
Courses Plus Student 2,527 PointsHi Zimri,
Thank you for comments which will provide further reading.
I think the UUID will prove too long for the users but makes for interesting reading.
In essence the Code will probably be 8 characters long and then converted into a QR Code for us to photograph to then convert back to the 8 Digit code for appending to the images.