dongxie2613 2012-06-19 06:18
浏览 34
已采纳

加密到短串[关闭]

What encryption scheme returns a short string? I want a small result less than 32 characters. I also want to be able to decrypt it back to the original plaintext. The purpose is email verification, where the code is sent by email. When the code is received the user logs in into the site and enters the code (or clicks on the link).

EDIT: DECRYPTION is important as after verification i need to relate two non related records

Thanks

  • 写回答

5条回答 默认 最新

  • duanhui9840 2012-06-19 11:03
    关注

    You're talking about encryption but clearly need a hashing function. You can then relate the hash to any data model you want (whatever it is you want to 'encrypt' in this case) in a database. The hash is used like the key of a key-value store and can be completely random. The final size of an encryted string is always directly related to the size of the original string. Otherwise you're probably confusing hashes and encryption.

    So a simple use-case:

    • A user registers into a website.
    • The registration controller creates a new record into the 'pending_users' table which has only 2 columns: user_id and random_key.
    • And email is sent to the user containing the value of the random_key which is exposed as a link to verification.php?key=$random_key

    When the user executes the verification.php controller, the controller checks for the presence of the $random_key in the pending_users table. If found, it removes the record and changes a flag in the users table (active_account = true for example). If not found an error is sent back to the user.

    Hope this helps, Cheers

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取