【问题标题】:Is it possible to retrieve an 8 digit number from the database using 6 digits是否可以使用 6 位数字从数据库中检索 8 位数字
【发布时间】:2021-07-15 18:25:28
【问题描述】:

我在数据库中为每个用户生成了一个唯一的 8 位数字,如下所示:

3 位前缀 |顺便说一句 01 和 99 的任何数字 |依次生成的 3 位数字。

例如:234 | 74 | 216 ==> 23474216

因为我希望用户容易记住这个号码,所以我打算只向用户发出 8 位数字中的 6 位数字。例如,使用上面的数字 23474216,用户得到 234742。

问题在于,用户必须仅依靠这 6 位数字才能访问系统。没有密码。

那么如何将 6 位数字与数据库中正确的 8 位数字匹配?

提前致谢。

【问题讨论】:

  • 那么 23474216 和 23474200 将获得访问权限?

标签: sql node.js math cryptography


【解决方案1】:

举例

Declare @p int = 23474216

select 
      @p as [number]
    , @p/100 as [short] -- because it is int type it will drop decimals
    -- if you have type string - use Substring()
    , Substring('23474216', 1, 6) as [string value]

【讨论】:

  • 感谢您的回复。我用这种方法遇到的问题是 23474216, 23474218, ... 因为最后 3 位数字以 2 开头
  • @twinsmaj 。 . .因此,你不能做你想做的事。你有碰撞。
猜你喜欢
  • 1970-01-01
  • 2019-03-10
  • 1970-01-01
  • 2018-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
相关资源
最近更新 更多