Page History: [PHP] 서명(signature) 생성 샘플코드
Compare Page Revisions
Page Revision: 2012/05/29 22:08
서명(signature) 생성 PHP 샘플코드
here is slight difference between .Net and PHP. While .Net expects byte array as key, PHP expects string as key. Thus we have to form string representing byte array.
<?php
$key = pack('c*', 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff);
$sig = hash_hmac('sha256', "t=HelloWorld&r=10", $key);
echo '<img src="http://mqr.kr/qr/?t=HelloWorld&r=10&sign='.$sig.'"/>';
?>