mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-06-11 12:25:12 +02:00
Add JavaScript version to render the hash digest.
parent
ba80c657d2
commit
8df2621a92
1 changed files with 11 additions and 0 deletions
|
|
@ -89,4 +89,15 @@ import base64
|
|||
key = 'secret key'
|
||||
data = 'https://octodex.github.com/images/codercat.jpg'
|
||||
print base64.urlsafe_b64encode(hmac.new(key, msg=data, digestmod=hashlib.sha256).digest())
|
||||
```
|
||||
|
||||
### JavaScript
|
||||
|
||||
```javascript
|
||||
import crypto from 'crypto';
|
||||
import URLSafeBase64 from 'urlsafe-base64';
|
||||
|
||||
let key = 'secret key';
|
||||
let data = 'https://octodex.github.com/images/codercat.jpg';
|
||||
console.log(URLSafeBase64.encode(crypto.createHmac('sha256', key).update(data).digest()));
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue