简体   繁体   English

如何存储和验证PIN码

[英]How to store and verify PIN code

I am developing a scratch-card voucher pin application 我正在开发刮刮卡凭证应用程序

  1. The 12 digit pin will be generated by pseudo-random tool 12位密码将由伪随机工具生成
  2. The pin (and a serialno) is tored in the database for authentication 销(和序列号)在数据库中分配给身份验证
  3. User type in the pin to use a service, and the pin is checked against the database for verification by scanning through the Pin Column 用户输入要使用服务的密码,然后通过扫描密码列来对照数据库检查密码以进行验证
  4. The pin should also be decoded (in rare cases) 引脚也应解码(在极少数情况下)

Problem If the pin is encrypted, it will be difficult query the database for the verification. 问题如果引脚是加密的,将很难查询数据库以进行验证。 Since the search is based on pin. 由于搜索基于图钉。 How do i store the pin code so that 我如何存储密码

  1. It can be unique, and matched during verification 它可以是唯一的,并在验证期间匹配

Just encrypt the pin and store it. 只需将密码加密并存储即可。 When the user enters the pin for verification, encrypt it also and compare the encrypted stored pin with the encrypted user-entered pin. 当用户输入密码进行验证时,也对其进行加密,并将加密的存储密码与加密的用户输入密码进行比较。 If you need to decode pin in rare cases, use a decodable encryption. 如果在极少数情况下需要解码引脚,请使用可解码的加密。 I would recommend not doing so and forcing the user to update to a new pin if he loses or forgets the old one. 我建议不要这样做,如果用户丢失或忘记了旧的密码,则强迫用户更新到新的密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM