Skip to main content

Rust Generate SHA1 Hash

· One min read
forfd8960
Author

the crate

[dependencies]
sha1-checked = "0.10.0"
base16ct = { version="0.2.0", features=["alloc"] }

Generate SHA1 Hash bytes

  • build sha1 hasher with Sha1::new()
  • update the hasher with hasher.update(content)
  • call hasher.try_finalize() to get the hash
  • generate hash bytes with
let arr = hf.hash();
arr.to_vec()

How Git Works

· 14 min read
forfd8960
Author

The internals want to know about Git

We as developers often use git to manage our code. But do you know how git works?

And as a Curious developer, I want to know how git works.

Some questions I want to know are:

  • How git stores the data(the code, the image etc)
  • What happens when run git add
  • How does git knowns which file is untracked.
  • Where does the data is been stored.
  • How git store the commit when you run git commit -m "message"
  • How git restore the repo when checkout to another branch.

Implement Git with Rust Part0

· 5 min read
forfd8960
Author

What is Git

We use git to manage our code, and do version control.

  • generally, I use git init or git clone to start a project locally.
  • And do some work in the git repo.
  • And then use git add to add the files to the staging area.
  • And then use git commit to commit the changes to the local repository.
  • And then use git push to push the files to the remote repository.
  • And then use git pull origin master to pull the changes from the remote repository.
  • use git checkout -b <new_branch> to create and checkout to a new branch.
  • use git rebase master to rebase changes from master to the current branch.

Rust Json Parser

· 6 min read
forfd8960
Author

What is Json

What is Json

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language Standard ECMA-262 3rd Edition - December 1999.

Deduplicate elements in Vec in Rust

· One min read
forfd8960
Author

How to Deduplicate the elements in a Vector

First Version

in the first version of the deduplicate:

  • First create data_set to matain the data exists state.
  • Iter over the data and check if the specific data in idx is exists
  • If exists then skip.
  • If not exists then push the data to new result: dedup_data.

Build A Simple Cli App with Rust

· One min read
forfd8960
Author

use clap to build a cli App

So, I want to build a Cli App that convert a csv file to json, yaml, toml formated file.

And for Rust, there is crate clap was used to build cli app.

And the final command to use the cli app, is something like this:

./target/debug/rcli csv -i test.csv