How to generate a verification code/number?

前端 未结 9 2034
慢半拍i
慢半拍i 2020-12-07 16:51

I\'m working on an application where users have to make a call and type a verification number with the keypad of their phone.

I would like to be able to detect if th

9条回答
  •  北海茫月
    2020-12-07 17:35

    You linked to the check digits project, and using the "encode" function seems like a good solution. It says:

    encode may throw an exception if 'bad' data (e.g. non-numeric) is passed to it, while verify only returns true or false. The idea here is that encode normally gets it's data from 'trusted' internal sources (a database key for instance), so it should be pretty usual, in fact, exceptional that bad data is being passed in.

    So it sounds like you could pass the encode function a database key (5 digits, for instance) and you could get a number out that would meet your requirements.

提交回复
热议问题