Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brantje/imageproxy
Small nodeJS image proxy
https://github.com/brantje/imageproxy
Last synced: 3 days ago
JSON representation
Small nodeJS image proxy
- Host: GitHub
- URL: https://github.com/brantje/imageproxy
- Owner: brantje
- Created: 2016-05-10T09:00:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-05-10T09:07:53.000Z (over 8 years ago)
- Last Synced: 2024-11-20T09:25:43.122Z (2 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#Imageproxy
Small nodejs server for for proxing http images to https.
Cache is set to 10 days.Usage:
```
https://imageproxy.local:8080/
```To generate the encrypted image url you can use the following example code:
```php
class Crypto
{
private $encryptKey = 'MySecretKey12345';
private $iv = '1234567890123456';
private $blocksize = 16;
public function decrypt($data)
{
return $this->unpad(mcrypt_decrypt(MCRYPT_RIJNDAEL_128,
$this->encryptKey,
hex2bin($data),
MCRYPT_MODE_CBC, $this->iv), $this->blocksize);
}
public function encrypt($data)
{
//don't use default php padding which is '\0'
$pad = $this->blocksize - (strlen($data) % $this->blocksize);
$data = $data . str_repeat(chr($pad), $pad);
return bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128,
$this->encryptKey,
$data, MCRYPT_MODE_CBC, $this->iv));
}
private function unpad($str, $blocksize)
{
$len = mb_strlen($str);
$pad = ord( $str[$len - 1] );
if ($pad && $pad < $blocksize) {
$pm = preg_match('/' . chr($pad) . '{' . $pad . '}$/', $str);
if( $pm ) {
return mb_substr($str, 0, $len - $pad);
}
}
return $str;
}
}
$crypto = new Crypto();
$url = 'http://i.imgur.com/Ssiz30z.png';
$encrypted = $crypto->encrypt($url);
echo '';
```