From 2fc9275552525af9d1804eb0ad34ee8bf4e1e237 Mon Sep 17 00:00:00 2001 From: phyknife Date: Fri, 25 Aug 2023 19:20:46 +0800 Subject: [PATCH] feat(git-craft): Upload Git-craft v0.1.0 and its Design Document --- git-encrypt/craft/.gitignore | 9 + git-encrypt/craft/Cargo.toml | 17 ++ git-encrypt/craft/README.md | 45 ++++ git-encrypt/craft/src/crypt.rs | 145 +++++++++++ git-encrypt/craft/src/encrypted_message.txt | 1 + git-encrypt/craft/src/lib.rs | 2 + git-encrypt/craft/src/main.rs | 196 +++++++++++++++ git-encrypt/craft/src/message.txt | 1 + git-encrypt/craft/src/pgp_key.rs | 256 ++++++++++++++++++++ git-encrypt/doc/clean.png | Bin 0 -> 84001 bytes git-encrypt/doc/doc.md | 51 ++++ git-encrypt/doc/eg.png | Bin 0 -> 108007 bytes git-encrypt/doc/keyfile.png | Bin 0 -> 38712 bytes git-encrypt/doc/pri.png | Bin 0 -> 585324 bytes git-encrypt/doc/pub.png | Bin 0 -> 458923 bytes git-encrypt/doc/smudge.png | Bin 0 -> 83616 bytes git-encrypt/doc/structure.png | Bin 0 -> 65972 bytes 17 files changed, 723 insertions(+) create mode 100644 git-encrypt/craft/.gitignore create mode 100644 git-encrypt/craft/Cargo.toml create mode 100644 git-encrypt/craft/README.md create mode 100644 git-encrypt/craft/src/crypt.rs create mode 100644 git-encrypt/craft/src/encrypted_message.txt create mode 100644 git-encrypt/craft/src/lib.rs create mode 100644 git-encrypt/craft/src/main.rs create mode 100644 git-encrypt/craft/src/message.txt create mode 100644 git-encrypt/craft/src/pgp_key.rs create mode 100644 git-encrypt/doc/clean.png create mode 100644 git-encrypt/doc/doc.md create mode 100644 git-encrypt/doc/eg.png create mode 100644 git-encrypt/doc/keyfile.png create mode 100644 git-encrypt/doc/pri.png create mode 100644 git-encrypt/doc/pub.png create mode 100644 git-encrypt/doc/smudge.png create mode 100644 git-encrypt/doc/structure.png diff --git a/git-encrypt/craft/.gitignore b/git-encrypt/craft/.gitignore new file mode 100644 index 00000000..18208ad1 --- /dev/null +++ b/git-encrypt/craft/.gitignore @@ -0,0 +1,9 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +#craft keys +key_files/* + +#filter config +.gitattributes \ No newline at end of file diff --git a/git-encrypt/craft/Cargo.toml b/git-encrypt/craft/Cargo.toml new file mode 100644 index 00000000..1b17dddc --- /dev/null +++ b/git-encrypt/craft/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "git-craft" +version = "0.1.0" +edition = "2021" + + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[workspace] + +[dependencies] +anyhow = "1.0.69" +pgp = "0.10.2" +rand = "0.8.5" +smallvec = "1.10.0" +clap = { version = "4.3.0", features = ["derive"] } + diff --git a/git-encrypt/craft/README.md b/git-encrypt/craft/README.md new file mode 100644 index 00000000..8b544bdf --- /dev/null +++ b/git-encrypt/craft/README.md @@ -0,0 +1,45 @@ +# Git-craft v0.1.0 + +Git-craft is a extension for git, it can encrypt the content when submitting code in Git, and rewrite the content of the Blob object and code decryption when reading the Blob content, with filter. + +## Prepare +1. cd mega/craft +2. modify all the key file path, KEY_FILE_PATH, MSG_FILE_NAME and filter to match your project +3. cargo build --release + +## Usage + +1. git-craft generate-key + - git-craft will default generate a public key to /key_files/pub.asc and a secret key to /key_files/sec.asc +2. git-craft generate-key-full [primary_id] [key_name] + - git-craft will generate key with primary id and key name you entered to default file path +3. git-craft encrypt [public_key_path] + - git-craft will get the file content and encrypt it, it should be used without public key path now, because I set a default key path +4. git-craft decrypt [secret_key_path] + - git-craft will decrypt blob data read from git's standard input stream, it should be used without secret key path now, because I set a default key path +5. git-craft list-keys [Option] + - git-craft will list keys name, key's fingerprint and id, it should be used without key path now, because I set a default key path +6. git-craft delete-key [key_name] [Option] + - git-craft will show you what keys you have now, then remove keys by key name you entered, it should be used without key path now, because I set a default key path + + + +## About Filter + +1. edit .git/config "../craft/key_files/sec.asc" is a default key, you can use another key. +- [filter "crypt"] + smudge = ../craft/target/release/git-craft decrypt ../craft/key_files/sec.asc + clean = ../craft/target/release/git-craft encrypt ../craft/key_files/pub.asc +2. edit .gitattributes +- file_need_crypted filter=crypt -text +- *.txt filter=crypt -text (it will use filter crypt at all txt file in this git dir) +3. must be used arguments + 1. Two commands below are used when you dont need crypt. + - git -c filter.crypt.smudge=noop