How to generate unique number of 12 digits?

前端 未结 4 1460
误落风尘
误落风尘 2021-01-03 17:08

I\'m working on an app that sends raw data to zebra printer and print out barcodes. And since every item has its own unique barcode, I need to define a variable that automat

4条回答
  •  迷失自我
    2021-01-03 18:03

    Using an RNG and a hash do:

    10 - stream out 12 digits
    20 - check if value is in hash
    30 - if it's goto 40 else goto 10
    40 - push value into hash
    50 - return new 12 digit number
    60 - goto 10

提交回复
热议问题