跳到主要内容

Hashing and digital signatures

哈希保护完整性

  • 我们用哈希来保护密码的保密性。哈希也能保护完整性 —— 证明数据未被改动。
  • 哪怕只改输入中的一个字符,哈希也会完全不同。
import hashlib
print(hashlib.sha256(b"hello").hexdigest()[:16])
print(hashlib.sha256(b"hellp").hexdigest()[:16])   # totally different

登录或创建账户

IGCSE, A-Level & AP