Go to file
2021-10-24 18:22:14 +02:00
.vscode New C++ header-only library 2021-10-24 18:22:14 +02:00
examples New C++ header-only library 2021-10-24 18:22:14 +02:00
src New C++ header-only library 2021-10-24 18:22:14 +02:00
_config.yml Set theme jekyll-theme-cayman 2017-08-16 15:57:31 +02:00
.gitignore New C++ header-only library 2021-10-24 18:22:14 +02:00
CNAME Create CNAME 2017-08-16 16:00:51 +02:00
LICENSE First commit 2017-05-06 18:32:27 +01:00
Makefile New C++ header-only library 2021-10-24 18:22:14 +02:00
README.md New C++ header-only library 2021-10-24 18:22:14 +02:00

PrimeModule-ext

C++ header-only library, binary and FFI library for factorizing huge (up to 2^63-1) numbers (optimized for huge semiprimes).

Install

Arch Linux (AUR):

paru -S primemodule

Debian/Ubuntu:

sudo apt-get install build-essential && git clone https://github.com/danog/PrimeModule-ext && cd PrimeModule-ext && make -j$(nproc) && sudo make install

API

Binary

primemodule number

On success (return code 0), prints to stdout one of the prime factors of number.

C++

uint32_t PrimeModule::factorize(uint64_t number);

Returns one of the prime factors of number, throws an std::runtime_error on failure.

C

int64_t factorize(uint64_t number);

Returns one of the prime factors of number, returns -1 on failure.

PHP

<?php

$f = FFI::load("/usr/include/primemodule-ffi.h");

// Always pass strings to allow 64-bit factorization with no loss of precision on 32-bit PHP.
var_dump($f->factorizeFFI("2189285106422392999"));

Returns one of the prime factors of 2189285106422392999, returns -1 on failure.