mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-20 05:29:17 +00:00

* Add some experiment code for crypto crate * feat: add crypto crate with ssl, rsa, ed25519 for https, encryption, signing * Implement aes encryption helper in crypto crate * ci: add dep for CI rust test (protobuf) * fix: try to fix window CI with next * fix: CI * ci: add dep for ubuntu * ci: fix * fix: openssl lib path in CI * fix: CI * update applications-rs, disable some tests * fix: CI * feat: add file transfer grpc proto and server setup * CI: try to fix CI * fix: missing proto in build.rs * ci: add cargo build before cargo test * fix: grpc file descriptor * ci: fix CI by removing a redundant main.rs * fix: disable local windows test in applications-rs which fails CI * ci: run CI rust test only on ubuntu, windows is failing. will be handled in another PR * fix: vue template * fix: allow unused variable * fix: remove node:buffer type from api shell.ts to avoid frontend build error * try to fix test in create-kunkun * upgrade api to 0.0.44, remove node:buffer * upgrade next template to 15 * feat: turn the default server into a https server * feat: make SSL certificate loadable from env * feat: add conditional SSL cert in debug mode, use local default cert, in production generate new self-signed cert every time app starts * chore: add vscode debug config * feat: add server public key * feat: setup sqlite db encryption * fix: settings hotkey * chore: add .gitkeep * ci: add node-fetch to dep for api package
38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
// use crypto::{Ed25519Crypto, Signature};
|
|
// use openssl::pkey::PKey;
|
|
// use openssl::rsa::{Padding, Rsa};
|
|
// use std::str;
|
|
|
|
// fn main() {
|
|
// let (private_pem, public_pem) = Ed25519Crypto::generate_key_pair_pem().unwrap();
|
|
// let message = b"hello world";
|
|
// let signature = Ed25519Crypto::sign(&private_pem, message);
|
|
// println!("Signature: {:?}", signature);
|
|
// }
|
|
|
|
use openssl::pkey::PKey;
|
|
use openssl::sign::{Signer, Verifier};
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
// Generate an Ed25519 private key
|
|
let private_key = PKey::generate_ed25519()?;
|
|
|
|
// The message to sign
|
|
let message = b"Hello, this is a test message!";
|
|
|
|
// Create a signer using the private key
|
|
let mut signer = Signer::new_without_digest(&private_key)?;
|
|
|
|
// Sign the message directly (no need to call update)
|
|
let signature = signer.sign_oneshot_to_vec(message)?;
|
|
|
|
println!("Message: {:?}", String::from_utf8_lossy(message));
|
|
println!("Signature: {:?}", signature);
|
|
// verify the signature
|
|
let mut verifier = Verifier::new_without_digest(&private_key)?;
|
|
verifier.update(message)?;
|
|
verifier.verify(&signature)?;
|
|
println!("Signature verified successfully!");
|
|
Ok(())
|
|
}
|