Ideas to create a small (<10 digits), not (very) secure “hash”

前端 未结 7 1342
暖寄归人
暖寄归人 2020-12-13 02:48

I\'m working on an online event ticketing system, where users will be able to self print his tickets and show up at the event where it will be scanned (barcode) and ideally

相关标签:
7条回答
  • 2020-12-13 03:37

    Here's a scheme that has the advantage of letting you calculate the next ticket hash from the previous (so you can verify whether one is missing), but doesn't let outsiders calculate the next one:

    Ticket.0 = substring(HASH(SALT + IV        ), 0, LENGTH)
    Ticket.i = substring(HASH(SALT + Ticket.i-1), 0, LENGTH)
    

    where

    • HASH is any hashing function that distributes its entropy relatively evenly across the output string
    • SALT is a constant you keep secret; it's a good idea to use a different one for each event
    • IV is another constant you keep secret
    • LENGTH is the length of the ticket ID you want (10 in your question, but 12 is not out of the question and gives you 256 times as many ticket IDs)
    0 讨论(0)
提交回复
热议问题