Skip to main content

사용자 정보를 블록체인으로 만들어주는 Python 패키지

Project description

blockchain-linker

한국어 | 영어

사용자 정보를 블록체인으로 안전하게 저장하고 관리할 수 있는 Python 패키지입니다. 간단한 인터페이스로 블록체인 구조를 이해하고, 데이터의 무결성을 직접 확인할 수 있습니다.

주요 특징

  • 사용자 정보 등 임의의 데이터를 블록체인에 저장
  • 블록체인 유효성 검증 기능 제공
  • 블록체인 저장 및 불러오기 지원 (JSON 파일)
  • 블록 데이터 수정 및 체인 재계산 기능
  • 직관적인 API와 예제 코드 제공

설치 방법

pip install blockchain_linker

빠른 시작 예제

from blockchain_linker import make_blockchain

users = [
    {"name": "Alice", "age": 30},
    {"name": "Bob", "age": 25}
]

chain = make_blockchain(users)
print(chain.to_list())
print('유효한 체인:', chain.is_valid())

# 체인 저장 및 불러오기
chain.save('chain.json')
loaded = chain.load('chain.json')
print(loaded.to_list())

주요 API

Block

  • 블록의 인덱스, 타임스탬프, 데이터, 이전 해시, 해시 정보를 가짐
  • to_dict(): 블록 정보를 딕셔너리로 반환

Blockchain

  • add_block(data): 새 블록 추가
  • is_valid(): 체인 유효성 검사
  • to_list(): 전체 체인을 리스트로 반환
  • save(filename): 체인 저장 (JSON)
  • load(filename): 저장된 체인 불러오기 (클래스 메서드)
  • modify_block_data(index, new_data): 특정 블록 데이터 수정 및 해시 재계산

make_blockchain(user_list)

  • 사용자 리스트로 블록체인 객체 생성

고급 사용 예시

from blockchain_linker import make_blockchain

users = [
    {"name": "Alice", "age": 30},
    {"name": "Bob", "age": 25}
]
chain = make_blockchain(users)

print("수정 전:", chain.to_list())

# 1번 블록(= Alice)의 데이터를 수정
new_data = {"name": "Alice", "age": 31, "city": "Seoul"}
success = chain.modify_block_data(1, new_data)
print("수정 성공 여부:", success)
print("수정 후:", chain.to_list())
print('유효한 체인:', chain.is_valid())

예제 실행

python examples/index.py

기여 방법

  1. 이슈/PR을 통해 자유롭게 의견을 남겨주세요.
  2. 코드 기여 전 반드시 테스트를 통과해주세요.

라이선스

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blockchain_linker-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blockchain_linker-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file blockchain_linker-0.1.0.tar.gz.

File metadata

  • Download URL: blockchain_linker-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for blockchain_linker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5af26240a6aeb48fe1198b252456e6df01a2ad29fdef7f48670ad4d85450091e
MD5 a2a9b61f719c89fce4393bd7f908cd60
BLAKE2b-256 29c81a08dc44b7b51f9b64d659109ab3281dcc8dd93b21c61930831da9edcccf

See more details on using hashes here.

File details

Details for the file blockchain_linker-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for blockchain_linker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1127f8cf845a338dd59747954a624d88f3d33163275eaa2e894fec9155e9106b
MD5 cd0daad29fdb52cdcfbc054dc8514931
BLAKE2b-256 225e934846cbbb3d849c85d3860e64421422cc51faa187eb20e2f9835ff2a818

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page