mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-06-11 04:15:12 +02:00
Add php example
parent
0b96a00978
commit
138cad0da0
1 changed files with 7 additions and 2 deletions
|
|
@ -91,7 +91,7 @@ data = 'https://octodex.github.com/images/codercat.jpg'
|
|||
print base64.urlsafe_b64encode(hmac.new(key, msg=data, digestmod=hashlib.sha256).digest())
|
||||
```
|
||||
|
||||
### JavaScript
|
||||
## JavaScript
|
||||
|
||||
```javascript
|
||||
import crypto from 'crypto';
|
||||
|
|
@ -102,11 +102,16 @@ let data = 'https://octodex.github.com/images/codercat.jpg';
|
|||
console.log(URLSafeBase64.encode(crypto.createHmac('sha256', key).update(data).digest()));
|
||||
```
|
||||
|
||||
### PHP
|
||||
## PHP
|
||||
|
||||
````php
|
||||
<?php
|
||||
$key = 'test';
|
||||
$data = "https://www.google.fr/images/srpr/logo11w.png";
|
||||
echo strtr(base64_encode(hash_hmac('sha256', $data, $key, 1)), '/+' , '_-');
|
||||
````
|
||||
|
||||
````shell
|
||||
$ php ex.php
|
||||
RYifAJRfbhsitJeOrDNxWURCCkPsVR4ihCPXNv-ePbA=
|
||||
````
|
||||
Loading…
Add table
Add a link
Reference in a new issue