I was playing around with OpenSSL again and here is some (hopefully) simple take to get familiarize with it’s capability.
Generate key pair and getting it’s modulus and exponent
Here are the openssl commands that operate to generate key pair and get the information about the generated key
- Generate key pair
openssl genrsa -aes256 -out private.pem 2048
- Get public key
openssl rsa -in private.pem -pubout -out public.pem
- Get private key (warning!)
openssl rsa -in private.pem -out private_plain.pem
the only difference with the above option is the -pubout option dropped
- Get the modulus from private.pem
openssl rsa -in private.pem -modulus -noout
- Get the modulus from public.pem
openssl rsa -pubin -in public.pem -modulus -noout
- Get modulus and exponent from public.pem
openssl rsa -pubin -in public.pem -text -noout
All commands above that operating on private.pem will require you to enter a pass phrase.
Modulus from both private.pem and public.pem are the same (as it should be).
OpenSSL default format is in PEM format, how about operating in DER format? Suppose we want to convert PEM format to DER, and operating with DER format
- Converting from PEM to DER
openssl rsa -pubin -inform PEM -in public.pem -outform DER -out public.der
- Get modulus from pu/blic.der (DER format)
openssl rsa -pubin -inform DER -in pub -modulus -noout
Print out x509 certificate information
Now that we know how to operate with different format via -inform, and we know how to print out info via -text. We generate a self sign certificate, mycert, https://www.madboa.com/geek/openssl/#how-dnerate-a-self-signed-certificate. Input the necenformation to create a cert.
- Print certificate information
openssl x509 -text -inform DER -in mycert.der -noout
Bummer, your small c apps compiler doesn’t have a getch().
We can overcome this by installing ncurses or create our own getch() function.
If you’re using cygwin, we should install ncurses first (it’s not included in cygwin’s default setup). First of all, you have to get libncurses-devel package.
Here is example how to use ncurses
Manual compile: gcc test_ncurses.c -lncurses
CMake example to compile
- Here is the solution for creating getch() function.
Here is my addition to my .vimrc config file this week.
First part is to load matchit.vim that already part of Vim distribution, it aiding a great help for me to browse through html file, it extend the
% vim command.
The second part is a bit tricky for FuzzyFinder plugin user, I want to exclude directory, in this case is “venv” directory, that apparently the regex matching work well with
fuf_file_exclude instead of
fuf_dir_exclude. You can add you excluded list by extending and following the line #9 from snippet above.
Git: distributed repository is the new centralize.
Common used git command. I keep it brief with no/minimum explanation of each command by hoping that those commands are self explanatory. I also organize by git trifecta of Add/Modify – Branch – Remote workflow.
Add, check and publish. The basic
git clone <repository-url>
- Adding/making changes
git add .
git add <path/file.name>
git commit -am “”
- Checking status
git log —-all —-graph —-oneline
git log branch1..branch2
- Getting updates
git fetch Fetches latest changes from origin
git pull Fetches latest changes from origin and merge
git push Push changes to origin from current
git push <origin> <branch> Push changes to origin from branch
Modify, fixing mistakes
- Revert commits
git revert HEAD
git revert <commit-ref>
- Revert/undo all changes
- Fix last commits
git commit –amend [-m “updated message”]
- Reset modifications
git diff $id1 $id2 Diff between 2 commits
- Resolving changes
git checkout –ours <path/file>
git checkout –theirs <path/file>
- Combine commits
- Creating branch
- Listing branch
git branch -a
git branch -v
- Switching branch
git checkout <branch-name>
git checkout -b <branch-name>
- Merging branch
git merge <branch-name>
git merge --squash <branch-name>
- Deleting branch
git branch -d <branch-name>
- Adding remote
git remote <remote-name> <remote-url>
- Listing remote
- Fetching/Pushing to/from remote
git fetch <remote-name>
git push <remote-name> <branch-name>
- Getting update without removing local
git stash pop
.gitignore file for ignore files or directories. For further reference for more detailed git usage, my go to is gitref.org.
.vimrc, vim config file that I use everyday.
I want to keep it simple by not having too much configuration in vimrc itself. There is a plugin to manage vimrc to make it cleaner and readable, however it will introduce extra configuration.
My idea with this vimrc is to share easily between machine, main machine, or remote compiler machine that we can ssh it. Only one setup is needed to modify by hand, the vundle package manager, that’s it.
Once we’re graduate from school we’re expected to learn some and rightfully knowledgeable on certain subject we’re pursuing.
Learning broad subject in schools or books doesn’t mean we’re really understand it. Once my teacher said that the best way to understand is to teach someone the subject that we want to master. Teaching the same subject make her easily solve many problem variants, that’s make sense.
Repetition is key.
We’re living in continuous learning experience, once we thought that we’re mastering something there’ll be something new that come up and have to deal with. I’d be take a step back and recall that knowledge is understood.
I make 2 mental step in the back of my mind to understand a subject:
- I need to explain to myself what is it in the nutshell and then go into it’s details.
- I should be able to explain and make them understand the subject matter to a 5 graders or my granny.
If I can’t make to the second step, I might not grasp the nutshell or I simply don’t understand it properly. Back to square one. It might take some time but it’s worth the time invested, once we understand it – it won’t simply goes away.
There are memes that showing contrast on approach to result.
One picture showing old and wrinkle vegan activist, and other picture showing old yet looks lively, vibrant actress coming with tag line she eats meats.
There’s also story telling that one lady did her diet, strictly controlling her food intake, take vitamins and supplements under professional supervision, did all health checks regularly. On top of that she also did her exercises. She died in her 50s. On the other hand, this guy eats everything, no control on his food intake, be it junk food or salt and sugar, walk and commute are counted as exercise. He’s in his 80s now, well and energetic with no signs of him slowing down.
Another familiar story that we have experienced it before is one students burning midnight oils for exams ended up with C grades, other lucky fella glance through textbook minutes before ended up with A.
Those stories present one facts and deliver opinions that minimal effort triumphant in the end of the day. Case by case basis, of course, but let sink in for a while, does it make a better version of you? Most probably not, it will make us depends on luck a lot.
Skimming get you A in Data Structure 1, might not be the case in Data Structure 2. Keep eating unhealthy might still you long life expectancy, but don’t you think it’s better if we have healthy lifestyle? Imagine if that 80 years old guy if he have healthy lifestyle, he might broke oldest man alive. That lady who passed away in her 50 might not reach 30 years if she didn’t have healthy lifestyle.
We control our own life. Be a better person, you know what best for you. Strive hard to that direction. This is one value that I want to instill in my family.