파이썬[Python]: hashlib - digest 메서드

hashlib 모듈 - digest 메서드(method)


/// 설명

update() 메서드에 의해 전달된 데이터의 결과(다이제스트)를 반환합니다.

※ 형식
shake.digest(length)

/// 예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import hashlib
 
test_hash = hashlib.new('shake_128')
test_hash.update(b'This is a string')
 
print(test_hash.digest(20))  # b'\xca\xb1?\xa3\x9d>\xec?[.T\xb1\x98\xbb<\xeb\xea\xa0=\x06'
print(test_hash.digest_size)  # 0
print(test_hash.block_size)  # 168
 
# The NIST standard
# Output size d = digest_size
# b = state_size = 1600 bit = 200 bytes
# Rate r = block_size = 1344 bit = 168 bytes
# Capacity c = b - r = 256 bit = 32 bytes
#
# Security strengths in bits = the number of operations
# Collision ->        min(d/2, 128)
# Preimage ->       >=min(d, 128)
# 2nd Preimage ->     min(d, 128)
cs

* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)


– 당신을 응원합니다. –

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

파이썬[Python]: 내장함수 - bit_length 메서드

C 언어: sin 함수, cos 함수, tan 함수