v0.3
This commit is contained in:
5
Makefile
5
Makefile
@@ -6,4 +6,7 @@ build-linux:
|
|||||||
|
|
||||||
build-win:
|
build-win:
|
||||||
cargo build --release --target x86_64-pc-windows-gnu --package zsdiff_all --bin zspatch
|
cargo build --release --target x86_64-pc-windows-gnu --package zsdiff_all --bin zspatch
|
||||||
cargo build --release --target x86_64-pc-windows-gnu --package zsdiff_all --bin zsdiff
|
cargo build --release --target x86_64-pc-windows-gnu --package zsdiff_all --bin zsdiff
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -Rf target/
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
use crate::utils;
|
|
||||||
use md5;
|
use md5;
|
||||||
use rsa::pkcs1::{DecodeRsaPrivateKey, EncodeRsaPrivateKey, EncodeRsaPublicKey};
|
use rsa::pkcs1::{DecodeRsaPrivateKey, EncodeRsaPrivateKey, EncodeRsaPublicKey};
|
||||||
use rsa::pkcs8::LineEnding;
|
use rsa::pkcs8::LineEnding;
|
||||||
@@ -179,7 +178,6 @@ impl Compressor {
|
|||||||
pub struct Encrypter {
|
pub struct Encrypter {
|
||||||
private_key: RsaPrivateKey,
|
private_key: RsaPrivateKey,
|
||||||
public_key: RsaPublicKey,
|
public_key: RsaPublicKey,
|
||||||
key_size: usize,
|
|
||||||
}
|
}
|
||||||
impl Encrypter {
|
impl Encrypter {
|
||||||
pub fn new_pair() -> Self {
|
pub fn new_pair() -> Self {
|
||||||
@@ -190,14 +188,12 @@ impl Encrypter {
|
|||||||
Self {
|
Self {
|
||||||
private_key,
|
private_key,
|
||||||
public_key,
|
public_key,
|
||||||
key_size: bits,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_private_key(private_key: RsaPrivateKey) -> Self {
|
pub fn from_private_key(private_key: RsaPrivateKey) -> Self {
|
||||||
let public_key = RsaPublicKey::from(&private_key);
|
let public_key = RsaPublicKey::from(&private_key);
|
||||||
Self {
|
Self {
|
||||||
key_size: public_key.size(),
|
|
||||||
public_key,
|
public_key,
|
||||||
private_key,
|
private_key,
|
||||||
}
|
}
|
||||||
@@ -205,7 +201,6 @@ impl Encrypter {
|
|||||||
|
|
||||||
pub fn new(private_key: RsaPrivateKey, public_key: RsaPublicKey) -> Self {
|
pub fn new(private_key: RsaPrivateKey, public_key: RsaPublicKey) -> Self {
|
||||||
Self {
|
Self {
|
||||||
key_size: public_key.size(),
|
|
||||||
private_key,
|
private_key,
|
||||||
public_key,
|
public_key,
|
||||||
}
|
}
|
||||||
@@ -220,7 +215,7 @@ impl Encrypter {
|
|||||||
let segment = self
|
let segment = self
|
||||||
.public_key
|
.public_key
|
||||||
.encrypt(&mut rng, Pkcs1v15Encrypt, seg)
|
.encrypt(&mut rng, Pkcs1v15Encrypt, seg)
|
||||||
.unwrap();
|
.expect("Can't encrypt segment");
|
||||||
out.extend(segment)
|
out.extend(segment)
|
||||||
}
|
}
|
||||||
Ok(out)
|
Ok(out)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ mod utils;
|
|||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::format;
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::{fs, io, time};
|
use std::{fs, io, time};
|
||||||
use utils::{Metadata, Zsdiff, get_hash};
|
use utils::{Metadata, Zsdiff, get_hash};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use crate::utils::Metadata;
|
use crate::utils::Metadata;
|
||||||
use clap::{Arg, ArgAction, ArgMatches, Command, Parser};
|
use clap::{Arg, ArgAction, Command, Parser};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::{io, time};
|
use std::{io, time};
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
@@ -177,18 +177,6 @@ async fn zspatch(filename: String, dest_dir: String) -> Result<(), io::Error> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
|
||||||
struct Args {
|
|
||||||
#[arg(short, long)]
|
|
||||||
filename: String,
|
|
||||||
#[arg(short, long)]
|
|
||||||
dest_dir: String,
|
|
||||||
#[arg(short, long)]
|
|
||||||
metadata: bool,
|
|
||||||
#[arg(short, long)]
|
|
||||||
check_hash: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> io::Result<()> {
|
async fn main() -> io::Result<()> {
|
||||||
let m = Command::new("ZsPatch")
|
let m = Command::new("ZsPatch")
|
||||||
@@ -216,12 +204,14 @@ async fn main() -> io::Result<()> {
|
|||||||
.arg(
|
.arg(
|
||||||
Arg::new("filename")
|
Arg::new("filename")
|
||||||
.short('f')
|
.short('f')
|
||||||
|
.long("filename")
|
||||||
.required(true)
|
.required(true)
|
||||||
.action(ArgAction::Set),
|
.action(ArgAction::Set),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("dest")
|
Arg::new("dest")
|
||||||
.short('d')
|
.short('d')
|
||||||
|
.long("dest")
|
||||||
.required(true)
|
.required(true)
|
||||||
.action(ArgAction::Set),
|
.action(ArgAction::Set),
|
||||||
)
|
)
|
||||||
@@ -256,20 +246,4 @@ async fn main() -> io::Result<()> {
|
|||||||
_ => unreachable!("Subcommand is required"),
|
_ => unreachable!("Subcommand is required"),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
// let args = Args::parse();
|
|
||||||
//
|
|
||||||
// let filename = args.filename.clone();
|
|
||||||
// let dest_dir = args.dest_dir.clone();
|
|
||||||
//
|
|
||||||
// if args.check_hash {
|
|
||||||
// check_hash(args.filename.clone()).await.ok();
|
|
||||||
// }
|
|
||||||
// if args.metadata {
|
|
||||||
// let diff = load_file(filename).await?;
|
|
||||||
// let metadata = diff.metadata;
|
|
||||||
// println!(">>> Compress level: {}", metadata.compress_level);
|
|
||||||
// return Ok(());
|
|
||||||
// }
|
|
||||||
// zspatch(filename, dest_dir).await
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user