2014-01-29 14:06
浏览 99


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?

图片转代码服务由CSDN问答提供 功能建议

我有一个生成二维码。 此代码将通过JavaScript中的PhoneGap应用程序读取。 到目前为止这个工作正常,但我想保护QR码,所以没有其他人可以生成其他有效的代码。

我的第一个想法是在QR码中添加数据的哈希值。 但常见的哈希函数不是很安全。 对于良好的哈希函数,我没有找到JavaScript的实现。 第二个想法是使用公钥/私钥加密,但这也是JavaScript的问题。

另一个巨大的问题是QR码应该很简单。 长加密将使小QR码不可读。


  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题