How to implement secret key in QR Code so that the scanner will recognize that 'yeah, this is my code' (something like that). I already search for the algorithm but i can't find it.
Asked
Active
Viewed 910 times
-1
-
1) a scanner has no provision to react to a particular content (except with a ReaderProgramming control code); 2) there will be no problem counterfeiting by photocopying the code. – Apr 24 '16 at 18:02
1 Answers
0
This is just a special case of "how to do I send a message and make sure it arrives intact and unmolested by third parties?". You do that with a Message Authentication Code. If you're using Python, you can use the hmac module to do most of the work. Just include the resulting digest in the QR code when producing it, then when reading it, compute the digest of the data and your secret key, and compare it to the digest stored in the code. If they match, your reader is all set to proceed.

Jay Kominek
- 8,674
- 1
- 34
- 51
-
I currently read about it. Based on what you said, does it mean that 'while generating the QR code, we will include the message that will be stored in the database, then the message will be decrypted. Then, when we scan the QR code, the scanner reads it and encrypt the secret key and compare it with the message in the database. Then only we can proceed to next step'? – user6248070 Apr 26 '16 at 02:21
-
You don't need a database, you just include extra information (the result of the MAC computation procedure) in the bar code. The reader then pulls the original message, and the MAC out of the bar code, and is able to determine validity with that alone. – Jay Kominek Apr 26 '16 at 03:00
-
Actually i'm working on a project about Attendance System using QR Code. That's mean, when the students come to class, they simply can scan their QR Code and their attendance has been recorded. Is it possible for me to use the method you talked just now? – user6248070 Apr 26 '16 at 03:13
-
Unless you really trust your students, this isn't a good use for bar codes, because as Yves notes, the barcodes can be copied. So one student could just photocopy and swipe a bunch of his friends' barcodes. All my suggestion would prevent is one student faking another student's barcode without having seen it. – Jay Kominek Apr 26 '16 at 04:01
-
what i don't understand is about how to insert the secret key into the QR Code – user6248070 Apr 26 '16 at 05:11