Is it possible for a QR Code to give a random, or at all different, number when scanned?

StackOverflow https://stackoverflow.com/questions/21872554

  •  13-10-2022
  •  | 
  •  

Вопрос

I'm trying to build a system for logging when various QR codes are scanned. At the moment how it works is the QR codes generate emails and send them, and I have a Python script that organizes the received emails and puts them into an excel spreadsheet.

However, the emails that are sent are always the same, and there's no way of verifying that the person was actually at the location and isn't just copying a new email and sending it. If the QR Code could somehow put a different number each time scanned, that'd be ideal. However, if it could just generate garbage information and work as a placebo, that'd also work.

So, is there any way to make one QR Code give some different information when scanned? Predictable or not?

Это было полезно?

Решение

I found a good solution: Use a URL that automatically runs a javascript something like the following code:

<!DOCTYPE html>
<html>
        <script type="text/javascript">
        function autoEmail()   
            { 
                location.href = "mailto:you@example.com?subject=Data&Body=Verification Code: " +(new Date().getTime());
        window.onload = autoEmail; 
        </script>
</html>

This'll automatically open up the default mail app, and will place a timestamp in the mail. This will always be a unique code, and if you want to randomize it you can encrypt it or perform any of many operations on it.

Другие советы

I'm afraid that you can't change what is read from the QR code unless you change the code. You'll have verify the source at some point up stream. Maybe in the app or on your server? Maybe if you send a random code in the e-mail so that you can make sure that each one is only used once.

It is best to think of QR codes as just another way of printing text. There is no way for a fixed printed URL to somehow be a different URL every time you look at it. Same for QR codes. They simply encode exactly what they encode.

Unless you can change the QR code over time (like it's on an LCD screen you control), no.

You can write a custom app with a secret key inside that signs a token in the QR code and then sends that on. ALthough this fails if someone can pass around a copy of the QR code image.

If you trust the device's GPS you can again write an app that sends along location to perhaps verify it.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top