doumei8126 2014-01-29 14:06
浏览 111
已采纳

PHP&JS加密/签名并验证QR码

I have a php script that generates a QR Code. This code will be read from a PhoneGap app in JavaScript. This works fine so far but I would like to secure the QR Code so none else can generate other valid codes.

My first thought was to add a hash of the data in the QR Code. but common hash functions are not very secure. For good hash functions I did not find a implementation for JavaScript. Second thought was to use public/private key encryption but here again is JavaScript a problem.

Another huge problem is that the QR Code should be simple. A long encryption will make the small QR Code unreadable.

What would be a good approach to secure a QR Code?

  • 写回答

1条回答 默认 最新

  • douhun7609 2014-02-18 10:22
    关注

    Add a hash using a shared secret to your ID like this:

    $qrcontent = $id . md5($id . $secret);
    

    So to create a new $qrcontent one needs to know the $secret. There are some simple hashes like crc32 so you don't need a fully implemented javascript md5 function for example. You can define how long / secure your hash should be.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样