Peter's private space
to develop skills, share ideas and experience, etc

Symmetric and Asymmetric Encryption

Almost everybody use encryption day by day, but most of us unaware of it. Every time you open a website with HTTPS (the S stand for Secure), (after a host validation) your data is encrypted between your device and the server. But why? And how?

The reason

It’s very simple. Only you and the other party who you “talk with” should be able to read your messages, nobody else. Every data you send or receive (the text on websites, messages, pictures, videos) go through a lot of network devices until they reach their destination, and unencrypted communication can be breached by any device or person between source and the target. For example, you want to check your bank account. Naturally, you don’t want to share those details with the world; this is why every bank’s website accessible only with HTTPS (the S stands for Secure) and not pure HTTP; after your browser or application validates you are connected to the machine you really wanted to, it builds up a tunnel where every exchanged bit masked, encrypted.

What is what?

Cryptography is the method of using mathematical principles to transmit or store data securely, so only those whom are intended to have access can read and process it. The process that encodes the messages you’ll transfer into a format that cannot be understood nor read by any other device between the two parties who communicate called encryption.
The sender encrypts the date and the receiver must decrypt the message to be able to process it. For the this process, keys are being used. There are different type of keys in cryptography, but now I’ll focus how the key is shared between the parties.

Symmetric encryption

Imagine you create a password protected ZIP file. Only the one who knows this password will be able to unzip it and access the real data. If you share the file with somebody, you must share the password as well; and everybody who has that secret key is able to decrypt and encrypt. This is why it isn’t so widely used on the internet; in case somebody catches the key (the password, in this example), the data isn’t protected anymore and if you change the password you must re-share that with everybody. This is the simplest kind of encryption.

Asymmetric encryption

This cryptography uses 2 related keys, a public and a private key. Anybody can encrypt data with the public key, but only the one with the private key can decrypt that. You must protect only the private key, the public can be shared on a network because one key can be used only to encrypt or decrypt, and only the other can do the opposite. Due to this, asymmetric cryptography is widely used on the internet, especially while browsing websites (pages with HTTPS uses it, for example) or communicating (in privacy aware chat platforms) because every time you initiate a connection with a service, you can share the public key with the other party through the network and even if somebody catches that, cannot decrypt the messages you receive as long as the private key is protected.

Wrist-based or chest strap HR monitoring?

There are a lot of questions on different forums if it worth to buy an HR monitoring chest strap or the wrist-based is enough. My answer usually depends on two factors:

  1. Do you have some extra money to buy the strap?
  2. How accurate data do you want to get about your training?

If the answer is yes and accurate, my reply is: yes, definitely.

How they work?

Newer and newer watches with wrist-based HR monitoring are being released every day, and they deliver more and more accurate sensors. In their User Manual they ask you to tighten the wristband around your wrist, keep the sensors clear, unscratched, and, of course, don’t wear anything between the watch and your skin. The problem is that even if you comply with all of this, there’s a chance the watch will move, your skin get wet, things you can’t avoid when you train or run. It also worth to know the OHRM (Optical Heart Rate Monitor) checks the blood flow dynamics changes by measuring the amount of light that is scattered by the blood in your veins. It means, if the above conditions aren’t met, it’ll deliver inaccurate data.
On the other hand, the chest strap uses ECG that checks the electrical activity of the heart; it should be placed as close to your heart as possible, but due to the nature of our skin, it can read electrical changes well a few centimeters away too, and, for the same reason, even if it moves a bit the collected information is more accurate.

So, the OHRM isn’t trustworthy?

That is trustworthy, however, simply it has much more factors that can interfere the sampling and with that, the result.
I’m training for a long time now, I feel when my pulse is above 100 beats per minute. Last week I was in the gym, doing resistance training. For this sessions I don’t bring my chest strap. I checked my watch and it showed my heart beats 104 times per minute. 5 seconds later only 78 times. 2 seconds and 85 times. Then 75, and short after that 110 times. Pushing weights doesn’t require knowing your HR, but having inaccurate records for your runs may mislead you with your required sessions.

If you want to know more

Hide iTerm2's zsh notification

The preinstalled Terminal application on a Mac is very basic, at least for me. Thus, I installed iTerm2 that provides a lot of features and functions I was missing; but for a long time now, the default shell in iTerm2 is Z shell. However, I already configured my Bash and I don’t plan to switch. So, what I need to do to avoid the notification “The default interactive shell is now zsh” every time I start a new session?
The solution is very easy:
1.) open the .bash_profile in your home directory:
vi ~/.bash_profile
2.) add the below line:
export BASH_SILENCE_DEPRECATION_WARNING=1

If you ever want to see the message again, just open the above file again and delete the extra line you just added.

Silence?

In the recent 3 months 21 days I didn’t write anything here. It is because there a few things that going on. I changed role within the company, from Customer Operation Engineer I became a Software Engineer for the Hadoop project, sustaining the released versions, backporting fixes for issues and bugs, so nowadays I learn the tricks and hows of coding, Jenkins, build systems and so on.
In June we started to renew a big part of our house, with all the dis/advantage of it: dust, trash, broken tiles, missing parts of different things, reorders, new and fresh look, et cetera. Soon it’ll be done, the next is repainting the walls and when that is also finished, I’ll return and continue writing. I have ideas and a few drafts I must work on :)

Increasing VO2 max

I’m not a professional runner. I never was. Actually 6 years ago I hated running and I didn’t understand what’s the point of it; going somewhere without finish line. But 5 years ago it changed, I gave it a chance and found a goal that I achieved a year later: running a half marathon.
Nowadays, especially during the COVID-19 quarantine, it’s one of the best ways to keep my health. But distance running takes a lot of time that I don’t want to invest into this sport; so instead of going for more and more kilometers now my goal is to increase VO2 max.

Increase what?

The VO2 max “is the maximum rate of oxygen consumption measured during incremental exercise; that is, exercise of increasing intensity. The name is derived from three abbreviations: “V” for volume, “O2” for oxygen, and “max” for maximum.” - Wikipedia
Increasing it means your physical performance and endurance gets better; your muscles burn oxygen to generate power, and, naturally, the more oxygen your muscles can burn the more power they can generate for you, thus, you’ll have more power. The two main factors that have effect on the value are the oxygen transport system (lungs and the heart that circulates the blood) and the muscles (that will utilise the oxygen-filled blood, they must have high capillary density). So, working on improving this performance indicator means your lungs, heart and muscles will also improve along the way.

How to do it?

There are two easy ways: interval- and hill runs. You can find plenty of training plans and tips, I won’t write yet another one; plus running isn’t my profession, others know things in this topic much better, believe me.
In my case, hill run training is the most obvious, where I live I can find an upward within 200 meters in any direction and even though I include it in every session, based on my experience, after a time the endurance increases slowly. I didn’t run for a bit more than half a year in 2019 and my VO2 max fell from 50 (in July) to 46 (in November). True, I measure it with my watch, not in a laboratory, still, I like to know how my performance evolves and it’s a way to see it. So, since November I try to go on as much hills as I can (I have 90 meters elevation per exercise, in average), and my indicator went back to 49 recently, in April.

How to determine it?

The only trustworthy way is in a laboratory. They have the equipment to record everything (amount of air you breath in and out, for example) it requires to calculate your accurate VO2 max; every other device gives only approximate value. Nowadays most of the fitness- and smart watches capable to do it, you need to start a run or cycling activity and maintain a fast pace for an extended time. Different equipments do it differently, you need to do some research for yours to know the exact process or calculation.

Things worth reading

How to Boost Your Cardio Fitness - Runner’s World
VO2 max: Everything you need to know - cnet
How Important is VO2 Max? What Does Yours Actually Mean? - RunnersConnect

... or watching

What Is VO2 Max And How Can You Increase It? - The Running Channel
What’s The Fastest Way To Increase VO2 Max - EndurElite
How To Improve Your VO2 Max - Global Cycling Network