Pin Generation

前端 未结 11 837
走了就别回头了
走了就别回头了 2021-01-31 05:26

I am looking to develop a system in which i need to assign every user a unique pin code for security. The user will only enter this pin code as a means of identifying himself. T

11条回答
  •  花落未央
    2021-01-31 06:16

    If we assume 100,000 users maximum then they can have unique PINs with 0-99,999 ie. 5 digits.

    However, this would make it easier to guess the PINs with the maximum number of users. If you can restrict the number of attempts on the PIN then you can have a shorter PIN. eg. maximum of 10 failed attempts per IP per day.

    It also depends on the value of what you are protecting and how catastrophic it would be if the odd one did get out.

    I'd go for 9 digits if you want to keep it short or 12 digits if you want a bit more security from automated guessing.

    To generate the PINs, I would take a high resolution version of the time along with some salt and maybe a pseudo-random number, generate a hash and use the first 9 or 12 digits. Make sure there is a reasonable and random delay between new PIN generations so don't generate them in a loop, and if possible make them user initiated.

    eg. Left(Sha1(DateTime + Salt + PseudoRandom),9)

提交回复
热议问题