Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions snaphax.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,22 @@ function isValidBlobHeader($header) {
else
return false;
}

function pkcs5pad($data) {
// Block size is 16 bytes
$needed_padding = 16 - strlen($data) % 16;
if ($needed_padding == 0) {
$needed_padding = 16;
}
return $data . str_repeat(chr($needed_padding), $needed_padding);
}

function decrypt($data) {
return mcrypt_decrypt('rijndael-128', $this->options['blob_enc_key'], $data, 'ecb');
return mcrypt_decrypt('rijndael-128', $this->options['blob_enc_key'], pkcs5pad($data), 'ecb');
}

function encrypt($data) {
return mcrypt_encrypt('rijndael-128', $this->options['blob_enc_key'], $data, 'ecb');
return mcrypt_encrypt('rijndael-128', $this->options['blob_enc_key'], pkcs5pad($data), 'ecb');
}

public function postCall($endpoint, $post_data, $param1, $param2, $json=1, $headers=false) {
Expand Down