Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rakurame96 committed Nov 26, 2024
1 parent 3fbc651 commit 5e75b39
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/symmetric_test/src/decrypted.docx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is test document for validating the CAS-LIB implemention and provide the examples usecases for the users
1 change: 1 addition & 0 deletions tests/symmetric_test/src/encrypted.docx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�Ί������97�Ú懚����1N5I[��`�?�BíϜ^�x&�W.m�|+ܮ���D�ͺz�H3.ق��br��lp��6�d�~��D��YJ^����� ��?��a;&��S�~w^��z
19 changes: 19 additions & 0 deletions tests/symmetric_test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::{fs::{File}, io::Write, path::Path};

use cas_lib::symmetric::{aes::CASAES256, cas_symmetric_encryption::CASAESEncryption};

fn main() {
let path = Path::new("./../../test.docx");
let file_bytes: Vec<u8> = std::fs::read(path).unwrap();
let aes_nonce = <CASAES256 as CASAESEncryption>::generate_nonce();
let aes_key = <CASAES256 as CASAESEncryption>::generate_key();
let encrypted_bytes = <CASAES256 as CASAESEncryption>::encrypt_plaintext(aes_key.clone(), aes_nonce.clone(), file_bytes);
let mut file = File::create("encrypted.docx").unwrap();
file.write_all(&encrypted_bytes);

let path = Path::new("encrypted.docx");
let file_bytes: Vec<u8> = std::fs::read(path).unwrap();
let decrypted_bytes = <CASAES256 as CASAESEncryption>::decrypt_ciphertext(aes_key, aes_nonce, file_bytes);
let mut file = File::create("decrypted.docx").unwrap();
file.write_all(&decrypted_bytes);
}
3 changes: 3 additions & 0 deletions tests/test.docx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a sample document.
It contains several lines of text.
We will use this document to demonstrate signing and verifying using RSA encryption.

0 comments on commit 5e75b39

Please sign in to comment.