diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-06-02 11:18:19 -0700 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-06-02 11:18:19 -0700 |
commit | 007becf8ef443a6da5c94e5d53cf4e92cb4b44cc (patch) | |
tree | 5caa4ab839cf9f91c31767b6b4ec1148724dfc5f /inc/media.php | |
parent | b9cf8ad44bcbbbded9d6e991f96b0d5f36310a9b (diff) | |
parent | 183a7b8845875e4a6b67e466cfff9f5163da3f17 (diff) | |
download | rpg-007becf8ef443a6da5c94e5d53cf4e92cb4b44cc.tar.gz rpg-007becf8ef443a6da5c94e5d53cf4e92cb4b44cc.tar.bz2 |
Merge pull request #226 from splitbrain/hmac
Implement HMAC for signature tokens
Diffstat (limited to 'inc/media.php')
-rw-r--r-- | inc/media.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/inc/media.php b/inc/media.php index e29a47631..18148a446 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1879,20 +1879,21 @@ function media_crop_image($file, $ext, $w, $h=0){ * cropped images have been internally generated - and prevent external * DDOS attacks via fetch * + * @author Christopher Smith <chris@jalakai.co.uk> + * * @param string $id id of the image * @param int $w resize/crop width * @param int $h resize/crop height - * - * @author Christopher Smith <chris@jalakai.co.uk> + * @return string */ function media_get_token($id,$w,$h){ // token is only required for modified images if ($w || $h) { - $token = auth_cookiesalt().$id; + $token = $id; if ($w) $token .= '.'.$w; if ($h) $token .= '.'.$h; - return substr(md5($token),0,6); + return substr(PassHash::hmac('md5', $token, auth_cookiesalt()),0,6); } return ''; |