Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 198ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
h

hashlib

Recently created Least recently created Recently updated Least recently updated

timmy / 使用 hashlib 進行哈希運算

Last active 5 hours ago checksum encryption hashing hashlib python security

hashlib 提供加密雜湊函式(如 MD5、SHA-256),適用於 密碼雜湊、數據完整性驗證、數字簽章 等場景。

0 0 0 4
1 import hashlib
2
3 data = "Hello, World!".encode() # 轉換為位元組
4 hash_object = hashlib.sha256(data)
5 hash_hex = hash_object.hexdigest()
6
7 print(f"SHA-256 雜湊值: {hash_hex}")