Reputation: 4022
I want to use a QR code to uniquely identify a particular place, so at this place you scan the QR code and the app knows where you have been.
I want to ensure that a user can't re-create this QR code and 'cheat' by 'checking-in' at a particular place multiple times by generating a copy of the QR code (using an API or whatever).
Is this possible with QR codes?
Upvotes: 0
Views: 2139
Reputation: 644
If i correctly understood your question, this is my solution. You want to create a JSON object which contains your data, the object should be signed, using something like HMAC. Encode Json to QR example
{
"data":{
"location":"lat/long"
},
"sign":"4bcb287e284f8c21e87e14ba2dc40b16"
}
Upvotes: 1
Reputation: 177
unfortunately no it is not possible with the qr code. its all to easy to make a copy of a a qr code.
there are apps on the android app store that can decode the qr code and save the data. quickmark is one such scanner
quickmark can also make a qr code, and save it to the device. as well as use the a photo of a qr code to scan.
you would need to use some sort of external verification.
i see one user already posted a possible solution to this.
but another solution (that i imagine would be more expensive) would be to assign each user their own code,
then put a scanner on location to scan the users code.
this would prevent spoofed locations because its your hardware doing the "checking in"
this is much in the same way belly works
if your unfamiliar with belly heres a video that walks through customer signup and checking in
Upvotes: 0
Reputation: 14334
Here's how I'd do it.
Create a QR code pointing to http://example.com/place1
When the user scans the code, they get taken to a website.
Then, use JavaScript to get the GPS location of where they currently are.
Get them to submit a web form which sends their location to your service.
Sample JavaScript
navigator.geolocation.getCurrentPosition(geoSuccess, geoStatus , { enableHighAccuracy: true });
Upvotes: 0
Reputation: 69977
Unless you can create a new one each time and keep track of its use then no, a person could take a picture of the qr code and then post it and someone could scan the copy with their phone or device. Maybe if you asked for gps coordinates to be sent as well, but then there is nothing to stop them from spoofing the gps along with the image.
Upvotes: 2