2. Travel

Gone are the days where the average human would spend 5–10 years with the same company. These up in coming generations are now looking at a 1–3 year turn over. Reason being is our loyalty and…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Unboxing the blockchain puzzle

Series: hash functions

I went to an event last week and watched a blockchain expert explain what the blockchain. I left that event thinking that how amazing and interesting the topic is and wanting to be able to join this exciting community. Which is where the genesis of this blog post came from.

Learning about blockchain technology can be very daunting in the beginning but with time and patience you are bound to get it. This blog series is really a way for me to further crystallize my knowledge on the subject matter.

This series will just to go over key concepts that is important to understand before getting into what a blockchain is and how it works. After this series you should have the tools to be ready to go and read other documentations to really discover what the technology does and what you can do to contribute to the technology or the crypto community.

To start off we are going to focus on the question: what is a hash function? In future posts I’ll talk about how this ties into how it is an important component in different blockchain protocols.

I hope you are bucked up because this is going to be a crazy ride ;P enjoy!

Sooo… what are hash functions?

You maybe thinking huh wtf that does not help me!!!

You can think of it as being a factory where some raw materials goes into the factory(steel, aluminum, copper, glass, rubber, and special fibers) and a finished product comes out of it say a Tesla Roadster ❤ ❤ ❤. The same exact Tesla Roadster is the output. The identical chassis, cooling system, brakes, battery, suspension ect … everytime the raw material goes into out factory.

If you are not a car person, again, not to worry, in the good old days before google people use to encrypt their passwords using hash functions. But now most hash functions are cracked now especially MD5 and SHA256 which we will talk about later.

But in our case you would pass in any type of data(strings, numbers, documents…ect.) and get out a hash.

But wait what is a hash!!!?

Not to worry…a hash is simply a fixed length hexadecimal number. A Hash is also referred to as digests, tag, hashes, hash values, hash codes.

A great way to fully understand how does a hash works is to simply test it out yourself.

But how??

Follow these steps:

This line require ‘digest’ is required to be able to work with a ruby module called Digest.

With this line md5 = Digest::MD5.new you may be wondering what does the :: (double colon) denote? It is called a scope resolution operator this determines what scope a module can be found under. So Digest::MD5 means that MD5(a hash function) is a definition stored in the Digest class.

This line md5.update ‘message1’ “takes in a string (in this case ‘message1’ ) and updates the MD5 string of whatever the user puts in.

SHA256 is another example of a hash function

To test this out fire up a new repl.it ruby session or just comment out the code that we pasted in before and just copy and paste the following code into repl.it :

We still need this line require ‘digest’ to give us access to the Digest module

Digest::SHA256 means that SHA256(a hash function) is a definition stored in the Digest module. Digest::SHA256 takes in a string (in this case ‘message1’ ) and is stored into

sha256 a variable to store the Digest::SHA256.hexdigest ‘message’ output.

AAAAANNNNNNNDDDDDD……..

That’s it!

What we went over in this post is what is a hash function and how does it work and we saw some examples of how it works in ruby.

The main purpose to show y’all this is to prepare you all for learning about blockchain. Hash functions are used and is vital in blockchain technology.

The next installment of Unboxing the blockchain puzzle we will be covering a little bit about Cryptography.

All sources:

Add a comment

Related posts:

The Top 7 Reasons People Are Leaving Your Website Quickly

Do you ever land on a website and then immediately hit the back button or close the browser tab? You probably do it a lot more than you realize. I did it twice just this morning. You do it because…

A Dollar Every Friday for a Free Uniform Day Helps the Homeless

Former Synermed CEO and president James Mason has been pursuing his passion of serving the homeless. Before retiring, James Mason used his influence as CEO to persuade Synermed employees to get…

Heed the Message Behind the Feeling

This is not mystical or weird. And, in fact by observation I see, sense, and know something is “off” with the man in the beard. Light conversation gives weight to his unhappy state. My feeling was…