|
1
|
|
3
@LazyZhu 对这块不熟,那么理论上 openssl_sign 和 hash_hmac 如果 key,data,algo 都一样的话,结果会是一样的么?
|
|
LazyZhuSep 17, 2014
4
一样的。
php的话可以这样: $src = 'foo'; $key = 'bar'; $digest = hash_hmac('sha1', $src, $key); echo base64_encode($digest); 还有Python的实现,只是将MD5换成SHA-1 http://en.wikipedia.org/wiki/Hash-based_message_authentication_code 目前只有hmac_sha1,其他方式的话得自己写lua模块来实现了。 |
|
LazyZhuSep 17, 2014
5
|
|
6
@LazyZhu 用代码确认了一下,ngx lua 里的 hmac_sha1 和 openssl sha1 sign 真的不是同一个东西。hmac_sha1 的输出要比 openssl sha1 sign 短很多。
|