Skip to content

Instantly share code, notes, and snippets.

@pixline
Created October 23, 2011 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pixline/1306856 to your computer and use it in GitHub Desktop.
Save pixline/1306856 to your computer and use it in GitHub Desktop.
Decodifica HEX -> Blowfish -> Plain Text
<?php
/**
* Decodifica HEX -> Blowfish -> Plain Text
* @license http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* pear install Crypt_Blowfish
* @link http://pear.php.net/package/Crypt_Blowfish/
*/
include('Crypt/Blowfish.php');
/* dati di prova */
$msisdn = "df23e3983f66459470ae5b733c898c95";
$sender = "0000000000";
$shared_key = "abcdefghjk";
/* decodifica hex->blowfish */
$decoded = preg_replace("'([\S,\d]{2})'e", "chr(hexdec('\\1'))", $msisdn);
/* eventuale codifica blowfish->hex di controllo */
#$encoded = preg_replace( "'(.)'e", "dechex(ord('\\1'))", $sender);
/**
* decodifica blowfish->dati
* richiede un doppio type casting per problemi di lunghezza/codifica con $result
*/
$bf = new Crypt_Blowfish( $shared_key );
$result = (int) $bf->decrypt( $decoded );
$real_sender = (string) $result;
var_dump($real_sender);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment