I ended doing the same thing as dna girl, but more verbose.
Also becaue the array is coming from an ini file, the array not being recognized as a hex values. so I added an intval().
function getInitializationVector() {
$ini = parse_ini_file('foo.ini');
$stringVector = explode(',', $ini['initialization_vector'] );
$iv = '';
foreach($stringVector as $theByte) {
$iv .= chr(intval($theByte, 16));
}
return $iv;
}
foo.ini :
initialization_vector=0x8D,0x9D,0x40,0x09,0x64,0x5A,0x6E,0xD4
p.s. You shouldn't need to store your IVs if you pad correctly. (but that is another story...)