Rails 大家知道 api key 的加密方式

hlcfan · 2012年03月15日 · 最后由 clc3123 回复于 2012年03月16日 · 4125 次阅读

经过查,我发现了http://stackoverflow.com/questions/1448455/php-api-key-generator 其中我觉得如下方式不错. Base62(MD5-HMAC(key, Normalize(referer))). This works great if the API is only allowed from one site. Just check the HMAC of the normalized referer and you know if the key is valid, no database access. You need to keep the HMAC key secret to do this.

不过不知道在 rails 里如何实现 HMAC 加密。

另外,大家有什么好的加密方式?谢谢。

查 activesupport 源码,有相关部分

$ ack hmac

需要 登录 后方可回复, 如果你还没有账号请 注册新账号