# Some questions about crypto

How to determine what type of encoding/encryption has been used?

This link discusses in the first answer a "128 bit" value. How do you know that it is 128-bit and what is a 128bit value?

If I md5sum a string on Linux and then do it on the internet, I get different results. Why is this? Same with any other hash algorithm.

## 2 Answers

In computers, we tend to talk in three bases, binary (base 2), decimal (base 10 - the one you are familiar with), and hexadecimal (base 16). Computers usually encode everything in binary digits

A bit is b-inary dig-it - a digit in base 2 that is either a 0 or 1. E.g., you could represent the decimal number 42 as 6 binary digits: 101010bin as 42 = 32 + 8 + 2 = 25 + 2 3 + 21.

Similarly every hexadecimal digit is a number between 0 and 24-1= 15 = fhex = 1111binary. The 16 hex digits are 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f. (Sometimes the last 6 characters are written in uppercase -- its the same letters).

So if you see a hash that looks like `b1946ac92492d2347c6235b4d2611184` you can immediately notice that there are 32 hexadecimal characters. Thus as every hexadecimal character is 4 bits, it is 32*4 = 128 bits.

While we are at it, should mention that a byte is a convenient unit -- most plaintext characters in a text file are represented in one byte of data; e.g., a 100 kilobyte plaintext file will have about 100,000 characters in it. A byte is 8 bits - in binary a number 0 and 255 = 11111111binary = ffhex) - two hexadecimal characters.

It's 128 bits because hashing with MD5 results in a 32 character hexadecimal number that is made up of 128 bits of data. (That is, 128 bits of "0"s or "1"s.)

Computers work in binary, and binary is made up of "0"s and "1"s. That is, either there's something there or there's not. A "bit" is either a "0" or a "1". So, in a 128 bit string there will be some combination of 128 "0"s and/or "1"s.

Because hexadecimal characters are 4 bits each, 32 chars * 4 bits = 128 bits.

Hashing with a CLI vs using a site on the Internet will produce different results depending whether you decide to include line breaks and such. Here's a good SO post regarding the question you have.