GitFlow

!assets/Pasted image 20250203182747.png Reference GirFlow Explained: https://youtu.be/Aa8RpP0sf-Y

February 3, 2025 · 1 min

SHA-256 (Secure Hash Algorithm 256-bit)

SHA-256 is a cryptographic hash function that produces a fixed-size 256-bit (32-byte) hash. It is deterministic, collision-resistant, and designed for security-critical applications. !assets/hashing-algorithm-sha256.png How SHA-256 Works Preprocessing: Pad the input to a multiple of 512 bits. Append a 1, then add k zeros, and finally append the original message length (64 bits). Initialize Hash Values: Use constants derived from the fractional parts of square roots of the first 8 primes (eight 32-bit words). Example: h0 = 0x6a09e667, h1 = 0xbb67ae85, .... Process Blocks: Split the padded message into 512-bit blocks. For each block: Expand the block into 64 words using a message schedule. Perform 64 rounds of compression using bitwise operations (e.g., XOR, AND, modular addition). Compression Function A compression function is applied to each block, creating a new hash value. This function involves mixing the bits of the current hash value and the message block. Iteration Repeat the compression function for each block, using the output of each iteration as input for the next. Final Hash: Combine the intermediate hash values to produce the final 256-bit digest. Example: SHA-256 for String “Hello” Input: “Hello” → ASCII 48656C6C6F. Padding: Length = 40 bits (5 bytes). Pad with 1, 407 zeros, and 0000000000000028 (hex for 40 bits). Hash Computation: After processing, the final hash is: 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969. Use Cases SHA-256 Cryptographic security in: Digital signatures (SSL/TLS certificates). Password storage (hashed+salted). Blockchain (Bitcoin transactions). File integrity verification (e.g., software downloads). Guarantees: Pre-image resistance, collision resistance.

January 29, 2025 · 2 min

C,C++ Code Style Guide

This guide provides step-by-step instructions for setting up consistent formatting, rules checking, and documentation for C/C++ code using clang-format, clang-tidy, and Doxygen in VS Code. Follow this guide to ensure uniformity across the team. 1. Prerequisites Before starting, ensure you have the following tools installed: VS Code (latest version) Extensions for VS Code: C/C++ (Microsoft) Doxygen Documentation Generator Command-line tools: clang-format clang-tidy doxygen Python (for pre-commit hooks) 2. Auto-Formatting Using clang-format clang-format is used for consistent code formatting. ...

November 28, 2024 · 3 min

Git Undo Mistakes

Undo Mistakes 😱 git restore filename will discard uncommited change for this file cannot be undone afterward git restore -p filename p stands for patches will ask for each change in this file to be restore or not git restore . undo all changes since last commit git commit –ammend -m “Commit Message” change commit message of last commit do not change already pushed commit git revert <SHA> it reverts specified single commit <SHA> can be seen through git log, eg. 74e3b2b it makes new commit by exactly doing opposite changes, so it is very safe git reset –hard 74e3b2b it resets HEAD to certain commit in history while deleting all the commits after it if commits just local then they are gone forever git reset –mixed 74e3b2b same as previous one but it will store all the changes from the removed commits as uncommited changes git restore –source 74e3b2b filename will restore this file to certain commit (just 1 file) git reflog it is advance version of git log Restore after hard reset it even stores history for certain time after git reset --hard you can git reset 74e3b2b but creating mew branch is preferred by git branch branch_name 74e3b2b Restore after deleting entire branch look for <SHA> from git reflog then git branch branch_name 36a46a1 Moving commit to another branch if you want to move cirtain commits from current branch to new branch git branch new_branch_name git reset HEAD~1 --hard if moving commit to already present branch git checkout branch_name git cherry-pick 36a46a1 git checkout previous_branch_name git reset --hard HEAD~1 Interactive rebase is very advance, dangerous and powerful tool read comments during the process Change commit history for example if you want to change commit history upto 3 commits before current HEAD git rebase -i HEAD~3 you can change/reword commit messages, delete/drop commits, squash multiple commits together

March 24, 2021 · 2 min