Otp.php 892 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Dy;
  3. class Otp
  4. {
  5. /**
  6. * 新建生成器
  7. *
  8. * @param string $secret 密钥 Dy\Crypt::base32_encode
  9. * @param int $digits 长度
  10. * @param int $preiod 变动间隔 htop时候有效 建议60
  11. *
  12. * @return void
  13. */
  14. public function __construct(string $secret, int $digits, int $preiod)
  15. {
  16. }
  17. /**
  18. * 顺序验证码
  19. *
  20. * @package int $index 序号
  21. *
  22. * @return integer
  23. */
  24. public function hotp(int $index)
  25. {
  26. }
  27. /**
  28. * 时序验证码
  29. *
  30. * @return integer
  31. */
  32. public function totp()
  33. {
  34. // code...
  35. }
  36. /**
  37. * 发行者:用户名
  38. *
  39. * 格式为 "issuer:username",获取地址后可以生成二维码提供给client
  40. *
  41. * @param String $issuer
  42. * @return String
  43. */
  44. public function url(String $issuer)
  45. {
  46. }
  47. }