Skip to content

Commit

Permalink
Add factorize_pq_pair function
Browse files Browse the repository at this point in the history
Closes #2.
  • Loading branch information
Lonami committed Sep 26, 2021
1 parent b105ae7 commit c274f4a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ fn decrypt_ige(cipher: &[u8], key: &[u8], iv: &[u8]) -> PyResult<Py<PyBytes>> {
Python::with_gil(|py| Ok(PyBytes::new(py, &plain).into()))
}

/// Factorizes the pair of primes ``pq`` into ``(p, q)``.
#[pyfunction]
#[pyo3(text_signature = "(pq)")]
fn factorize_pq_pair(pq: u64) -> (u64, u64) {
grammers_crypto::factorize::factorize(pq)
}

#[pymodule]
fn cryptg(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(encrypt_ige))?;
m.add_wrapped(wrap_pyfunction!(decrypt_ige))?;
m.add_wrapped(wrap_pyfunction!(factorize_pq_pair))?;
Ok(())
}

0 comments on commit c274f4a

Please sign in to comment.