"함수 hash hmac()"의 두 판 사이의 차이

7번째 줄: 7번째 줄:
echo hash_hmac('ripemd160', 'The quick brown fox jumped over the lazy dog.', 'secret');
echo hash_hmac('ripemd160', 'The quick brown fox jumped over the lazy dog.', 'secret');
// b8e7ae12510bdfb1812e463a7f086122cf37e4f7
// b8e7ae12510bdfb1812e463a7f086122cf37e4f7
</source>
<source lang='php'>
echo hash_hmac( 'sha1', 'hello world', 'secret' );
# 03376ee7ad7bbfceee98660439a4d8b125122a5a
</source>
</source>
<source lang='php'>
<source lang='php'>
12번째 줄: 16번째 줄:
echo base64_encode( $h );
echo base64_encode( $h );
# Azdu5617v87umGYEOaTYsSUSKlo=
# Azdu5617v87umGYEOaTYsSUSKlo=
</source>
<source lang='php'>
echo hash_hmac( 'sha1', 'hello world', 'secret' );
# 03376ee7ad7bbfceee98660439a4d8b125122a5a
</source>
</source>



2016년 3월 3일 (목) 17:25 판

hash_hmac()

1 PHP

echo hash_hmac('ripemd160', 'The quick brown fox jumped over the lazy dog.', 'secret');
// b8e7ae12510bdfb1812e463a7f086122cf37e4f7
echo hash_hmac( 'sha1', 'hello world', 'secret' );
# 03376ee7ad7bbfceee98660439a4d8b125122a5a
$h = hash_hmac( 'sha1', 'hello world', 'secret', true );
echo base64_encode( $h );
# Azdu5617v87umGYEOaTYsSUSKlo=

2 Python

import hmac
import base64
h = hmac.new('hello world').digest()
print( base64.b64encode( h ) )
# sGXfsWEMawIp9we7B/iuuA==
import hmac
import base64
import hashlib
h = hmac.new('secret', 'hello world', hashlib.sha1).digest()
print( base64.b64encode( h ) )
# Azdu5617v87umGYEOaTYsSUSKlo=

3 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}