Giter VIP home page Giter VIP logo

ntc-pcrypto's Introduction

ntc-pcrypto

ntc-pcrypto is module python cryptography

Installation

From pip:

pip install ntc-pcrypto

From Source:

git clone https://github.com/congnghia0609/ntc-pcrypto.git
cd ntc-pcrypto
python3 setup.py install

Check version

pip show ntc-pcrypto

1. An implementation of Shamir's Secret Sharing Algorithm 256-bits in Python

Usage

Use encode/decode Base64

from sss.sss import *

s = "nghiatcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
print("secret:", s)
print("secret.length:", len(s))
# creates a set of shares
arr = create(3, 6, s, True)
# combines shares into secret
s1 = combine(arr[:3], True)
print("combines shares 1 length =", len(arr[:3]))
print("secret:", s1)
print("secret.length:", len(s1))

s2 = combine(arr[3:], True)
print("combines shares 2 length =", len(arr[3:]))
print("secret:", s2)
print("secret.length:", len(s2))

s3 = combine(arr[1:5], True)
print("combines shares 3 length =", len(arr[1:5]))
print("secret:", s3)
print("secret.length:", len(s3))

Use encode/decode Hex

from sss.sss import *

s = "nghiatcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
print("secret:", s)
print("secret.length:", len(s))
# creates a set of shares
arr = create(3, 6, s, False)
# combines shares into secret
s1 = combine(arr[:3], False)
print("combines shares 1 length =", len(arr[:3]))
print("secret:", s1)
print("secret.length:", len(s1))

s2 = combine(arr[3:], False)
print("combines shares 2 length =", len(arr[3:]))
print("secret:", s2)
print("secret.length:", len(s2))

s3 = combine(arr[1:5], False)
print("combines shares 3 length =", len(arr[1:5]))
print("secret:", s3)
print("secret.length:", len(s3))

License

This code is under the Apache License v2.

ntc-pcrypto's People

Contributors

congnghia0609 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.