No project description provided
Project description
factorizer
This is a simple factorization tool.
Here is the simplest example.
from factorizer import BruteForceFactorizer
divider = BruteForceFactorizer()
divider.factorize(57) # Devide number in order, starting with 2, 3, 4, 5...
#>>>(3, 19)
Install
Requirements
- boost
if you are using apt, you can install with
apt install libboost-dev
Install
You can just use pip to install
pip install factorizer
Usage
Basic Usage
first, import package
from factorizer import BruteForceFactorizer
BruteForceFactorizer
trys dividing given number with 2, 3, 4, 5...
All Methods in this package are listed below.
second, create a object
divider = BruteForceFactorizer()
then, call factorize()
method to factorize a number.
divider.factorize(57)
#>>> (3, 19)
You will receive the tuple, whose length are 2 and the product of those are the given number.
That's all!!
Setting Timeout
When you try to factorize some large numbers, what we care is whether the calculation ends in a short period. While we can't predict the required time, we provide time out method instead.
from factorizer import BruteForceFactorizer
divider = BruteForceFactorizer()
divider.factorize(221) # This takes less than 1 second.
# >>> (13, 17)
divider.factorize(144483604528043653279487) # This takes about 40 seconds in my environment.
# >>> (2147483647, 67280421310721)
Now you can set timeout for divider.
from factorizer import BruteForceFactorizer
divider = BruteForceFactorizer(timeout=5)
divider.factorize(221)
# >>> (13, 17)
divider.factorize(144483604528043653279487) # This raises timeout error after 5 seconds.
# >>> factorizer.TimeOutError
Factorize Methods
SIP... Sorry!
BruteForceFactorizer
FermatFactorizer
PollardsRhoFactorizer
RSAPrivateKeyFactorizer
FactorDBFactorizer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for factorizer-0.5.2-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 175c9c2f64ed87c6c10e2de548d5c5d2a2175cdc56a146705da703cfd0e6b568 |
|
MD5 | de6dbc484f29113b51e8e3688b307123 |
|
BLAKE2b-256 | 2f92c049c75ef2d08d29b9e1a2c07ca74c01af374d386835f4df3ed882455bf3 |
Hashes for factorizer-0.5.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b88d4658877209b2bf52adab1a91660d5b0c00ea70653010b8a8333f7e3a5ec2 |
|
MD5 | 43c37f823892dc178275e0fbea5b82d2 |
|
BLAKE2b-256 | 8b5f1515fa329b22daca6544264166c5639a0ff84f620e7b7bb25d9fa84a0595 |