Skip to content

Commit

Permalink
feat: bind GCM intial bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGw committed May 31, 2024
1 parent 597db6c commit 375247a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/gcm_rs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from gcm_rs import *

print(gen_key())
print(gen_key())
a = GCM()
5 changes: 5 additions & 0 deletions rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod gcm;
pub mod random;
pub mod types;

use gcm::Aes256Gcm;
use random::{gen_key as gk, gen_nonce as gn};

use pyo3::prelude::*;
Expand All @@ -19,10 +20,14 @@ fn gen_key() -> PyResult<Vec<u8>> {
Ok(gk())
}

#[pyclass]
struct Gcm(Aes256Gcm);

#[pymodule]
#[pyo3(name = "_lib_name")]
fn pyrust(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(gen_nonce, m)?)?;
m.add_function(wrap_pyfunction!(gen_key, m)?)?;
m.add_class::<Gcm>()?;
Ok(())
}

0 comments on commit 375247a

Please sign in to comment.