mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-06-27 05:49:38 +02:00
add python signing example
parent
4a5b1d85a6
commit
f08cb7e7e2
1 changed files with 12 additions and 0 deletions
|
|
@ -77,4 +77,16 @@ puts Base64.urlsafe_encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'),
|
||||||
```shell
|
```shell
|
||||||
% ruby sign.rb
|
% ruby sign.rb
|
||||||
RYifAJRfbhsitJeOrDNxWURCCkPsVR4ihCPXNv-ePbA=
|
RYifAJRfbhsitJeOrDNxWURCCkPsVR4ihCPXNv-ePbA=
|
||||||
|
```
|
||||||
|
|
||||||
|
## Python
|
||||||
|
|
||||||
|
```python
|
||||||
|
import hmac
|
||||||
|
import hashlib
|
||||||
|
import base64
|
||||||
|
|
||||||
|
key = 'secret key'
|
||||||
|
data = 'https://octodex.github.com/images/codercat.jpg'
|
||||||
|
print base64.b64encode(hmac.new(key, msg=data, digestmod=hashlib.sha256).digest())
|
||||||
```
|
```
|
||||||
Loading…
Add table
Add a link
Reference in a new issue