Giter VIP home page Giter VIP logo

pyjsbn-rsa's Introduction

pyjsbn-rsa

Python RSA module compatible with jsbn.js.

Installation

pyjsbn-rsa is available via PyPI

pip install pyjsbn-rsa

via setup.py

python setup.py install

Basic Use

You can test module with jsbn's RSA Encryption Demo

>>from jsbn import RSAKey
>>rsa = RSAKey()
>>rsa.generate(1024,"10001")
>>hex(rsa.n)
0xdc36096d038a56e84c6290f33db80dce54413e89dc15f0490dde8f1f58e69d957eed66c9537918b8fefd6a3fc9fc7b2551ac595bc77c2b98bcfa13f7deb17e94890ae4f28016f0d3e09450054263ae71f81539b09ea42b854492691e94de5671835b4ce91b9756b651ec4bbebe63eec8b7274e157b8de07457f2d3563119ac53L

Paste rsa.n to demo's Modulus (hex) and press encryt. (without "0x" and "L") And, get Ciphertext (hex) value

>>ctext="ceffa610eb7ec7fcbda60b2fdecf6d7cc65b7304ecb6e327056f15d763f1d079d376dbc801861a0ccb2731f836e75de0bb22350b3cd0d18eed216619b9e64a59dc06e15ef2531f0d3c176882444c5919dd751e9bcaefadff372d847b001a298751ebc69f9d310d92c217ab2fa433e3b3c7e8edf4744849560a317ef7f4ee7266"
>>rsa.decrypt(ctext)
'Hello World!'

Methods

You can use main methods of rsa.js and rsa2.js

setPublic

Set the public key fields N and e from hex strings.

>>rsa.setPublic(n,e)

setPrivate

Set the private key fields N, e, and d from hex strings.

>>rsa.setPrivate(n,e,d)

setPrivateEx

Set the private key fields N, e, d and CRT params from hex strings.

>>rsa.setPrivateEx(n,e,d,p,q,dp,dq,c)

encrypt

Return the PKCS#1 RSA encryption of "text" as an even-length hex string. You should do setPublic, setPrivate, setPrivateEx or generate first. text must be unicode for Python 2 and str for Python 3.

>>rsa.encrypt(text)

decrypt

Return the PKCS#1 RSA decryption of "ctext". "ctext" is an even-length hex string and the output is a plain string. You should do setPrivate, setPrivateEx or generate first.

>>rsa.decrypt(ctext)

generate

Generate a new random private key B bits long, using public expt E

>>rsa.generate(b,e)

pyjsbn-rsa's People

Contributors

pusnow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

shalomz 0xjz

pyjsbn-rsa's Issues

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.