Introduction to Encoding and Decoding

What is a code?  A code is a way to represent information in a different way than its original presentation.  The different representation can be used to make it so only those that know how to decode the message can understand the information.  A code also can be changing the way information is presented to make it more readable to other people or systems.  Louis Braille generated a code that allowed blind people to read books.  The sight book are encoded into different bumps on paper that allow the blind to read the information.  This encoding is known as braille.

Encoding Examples

Braille is one form of encoding.  Letters and Arabic numerals are another form of encoding. Changing a text from one language to another such as French to Italian would be another example of encoding the same information in different ways so others can read it or to prevent those who don’t know how to decode the message from reading it.

Many of the examples I have given are examples of how people send encode and decode messages.  Computers are machines.  A machine like an engine are generally built for one purpose, like making the wheels on the car turn allowing us to drive down the road. Computers are built for a purpose as well, math, logic and data operations which I discussed in my previous article.

How do machines store information?  Much like a printing press stores different letters in a book.  The book would be the memory.  The printing press writes each letter and the information is transferred to the hard copy, a book.

The way computers store information is much the same. Computers have many different technologies and mechanism and different types of memory but at the basic level they store information with light switches (figuratively speaking).  If a light switch is turned on, it is represented as a 1.  If a light switch is turned off, it is represented as a 0.  This allows us to store two representations which is called binary.  Computers speak in binary and other encodings like we speak in English or other languages like Chinese or Spanish.  So how would one represent a number like 7 or 3 in binary? Binary only has two values which are 0 and 1 which makes this a bit confusing.  Much like we can add numbers in the front of 7 to say make 17, or 27, or 37 we can add values in front of binary to represent greater values.

What are some examples of binary encoding?

Normal Decimal Number Binary
0 0
1 1
2 10
3 11

From the table above we can see that 0 and 1 have the same values in decimal as they do in binary.  Binary can represent those two numbers without having to add a greater value.  Binary can’t represent 2 or 3 in just 0s and 1s so it needs to add a greater value, so to represent a 2 it adds 1 to the front.

In decimal we represent each digit progressing left as a multiple of 10. That is why decimal encoding is considered base 10.  In binary we represent each value in multiples of 2, that is why we consider it base 2.

Binary Number Decimal Number
0 0
1 1
10 2
100 4
1000 8

The way to convert a binary number to decimal is we need to look at the position of the 1.  We generally ignore 0s as they represent values we don’t have to add.  When considering position the first position is considered position 0. So at position 0 for binary 1 or 0 we just add that value.

Position 1 in binary is where we have to multiply by 2. So if the binary encoding is 10 then we multiply the 1 in Position 1 by 2.  So 10 is represented as 2.  Further 11 is represented as 2 (from the first position) + 1 = 3.

Further representations are the same way. If we look at 100 we take then its Position 2. We find the decimal number by 1 multiplied by 2 to the exponent of the position.  Generally in computer programming we represent exponent operand as ^.

100 = (1)*2^2 + (0)*2^1 + (0)*2^0 = (1)*4 + (0)*2 + (0)*1 = 4

More examples

101 = (1)*2^2 + (0)*2^1 + (1)*2^0 = (1)*4 + (0)*2 + (1)*1 = 4 + 0 + 1 = 5
110 = (1)*2^2 + (1)*2^1 + (0)*2^0 = (1)*4 + (1)*2 + (0)*1 = 4 + 2 + 0 = 6
111 = (1)*2^2 + (1)*2^1 + (1)*2^0 = (1)*4 + (1)*2 + (1)*1 = 4 + 2 + 1 = 7

These are examples of decoding binary numbers into decimal numbers.  Examples of encoding from decimal into binary is similar except we use division and look at the remainders instead of multiplication.  Below is a useful link that shows the longhand division.

Decimal number Conversion Binary
0 0/1 would give no remainder 0
1 1/2 would give a remainder of 1 1
2 2/2 = 0 remainder and 2/1 would give remainder 1, flip this to 10 10
3 3/2 = 1 remainder and 2/1 would give remainder 1, flip this to 11 11
4 4/2 = 0 remainder and 2/2 would give 0 remainder, 2/1 would give remainder 1, flip this to 100 100

Other computer encodings:

Decimal number
(Base 10)
Binary
(Base 2)
Oct
(Base 8)
Hexadecimal
(Base 16)
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
100 1100100 144 64
1000 1111101000 1750 3E8

 

This article will be a precursor to hopefully some other articles on base 64 encoding and then encryption.

Ethics of Encoding

All technology can be used for good purposes and bad purposes.  Intelligent people know they can create associations with certain things in peoples mind.  They can tie colors or numbers to different things in society.  They can use this to break down communication between families, cities, and states.  Many times those that create encodings such as these don’t understand the full ramifications of all their actions.

These encodings can be used to teach bullies a lesson or they can be the instrument of bullies themselves.  Street names or other companies names could be taken out of context.  Through this they can derail companies or societies themselves.  It is a bit of a chicken and an egg problem.  Did the company know their name would be taken out of context or did others leverage their name to bankrupt the company.  A little bit of knowledge goes a long way.  I don’t understand any different human languages and not being able to pick up on puns or other types of encoding in other languages or multiple languages might be a blessing in disguise.  The idea that we should all think better of other people doesn’t only help them, it generally helps us.  When a group of people builds mistrust in any person it can make them question who is on the level and who is not.

Important to understand that mixed with different types of drugs these encodings and associations can be leveraged to manipulate people in to acting in certain ways, both good and bad.  Also sad to say that health problems and other issues that are no fault of the person can be leveraged by others for this same purpose.  This is why we need vigilant people to be able to understand what is going on at different times.  We also need to watch closely that some master plan isn’t unfolding right between our eyes.  Disrupting this encoding can be important at times.

It is sometimes difficult to know which side of the fence a person is on, so telling this to people might let you know your onto them.  Yet not telling someone this can make them appear to be a certain way that they are not.  Others might prefer to orchestrate someone else telling them because they are too afraid to say so themselves, definitely understand both sides of the coin on that one.

People use encodings as well, through non verbal communication.  Things that might be obvious to others might not be so obvious to someone else.  Proceeding with a level of caution with all human beings is extremely wise.  We don’t know what the other person has been through, nor what health problems they have.  This can change on a daily basis which can make this even more difficult.  Add in drugs and alcohol and it can be a recipe for disaster.  All that said, many of us don’t hear this, or we don’t understand in the way it was communicate to us.  Maybe someone would try but because of other issues they weren’t able to listen, or maybe the people that should have said something didn’t have the capacity at the time.  This is why grace is important, it not only helps others but also frees ourselves down the line from paying for things we didn’t understand at the time.  That said people that understand this might be less likely to take chances going forward, the probabilities and possibilities of failure can be overwhelming to the point they choose not to act and fail to speak up when necessary.

I generally try to look at the motivations behind a persons actions, though even this can be deceptive.  Some people might want to make others take pity on you by being mean.  I consider this a bit of a failed logic.  Others might just want to spar a bit but it would be wise to make sure both are at capacity for a fair fight and people aren’t actually getting hurt.  The main point from above being that people can encode information in different ways and that others don’t always understand the information encoded which can result in miscommunication.

This is also why living in cities can be difficult.  There are more interactions and less time to deal with those interactions in a graceful way.  People in cities might have just experienced 100 problems that are out of our control, if they sound like a jerk, it might not be because of us.  We would like to be able to expect they will treat us with kindness and treat us as we would like to be treated, but at that point in time, they just might not have the capacity.  Giving a person who seams mean or unhappy the benefit of the doubt and trying to do right by them the best we can might not make things better with our interaction, but it might help ease their burden or prevent problems down the line.  Excessive pressure on any person, organization, or society can cause it to collapse.  I don’t want to clean up the mess, so hears to hoping I will have the capacity to give others the grace they need.  Remember also that others can reverse this process to try and destroy people, then use it as an excuse to go to war.

 

Links to similar articles

http://www.wikihow.com/Convert-from-Decimal-to-Binary

Introduction to Computer Programming

Many articles have been provided for me to read over the years that have helped me learn more about development.  This will be an attempt to help the community learn more about computers and how to program.  This is not an attempt to replace any other articles already written on how to program.  I have been in the industry for years and hopefully can communicate valuable information to those starting out.  This might also give some basic knowledge to those who want to understand the basics, because as technology evolves our lives will be shaped by its influences, both good and bad.

What is a variable?

A variable is like a piece of paper.  It is a place to store information.  In computers we call this memory.  For the purposes of this tutorial we will use variables like X and Y. Computers find answers and then store the information they find so they can make decisions based upon those answers in the future.

What is an instruction?

An instruction is similar to a command.  It tells a computer one thing to do.  Computers are great with Math.  At the basic level we can instruct a computer to add, subtract, multiply, divide, make logic choices, and move information from one place to another.  These are the basic building blocks of all programs.

Examples of instructions:

  • 1+2
    • If I tell a computer to add 1 and 2 then the computer will return the answer 3
  • 10/2
    • If I tell a computer to divide 10 by 2 then the computer will return the answer 5
  • X = 4
    • If I tell a computer X equals 4,  then the computer will store the number 4 in the variable X

What is a program?

A program is a set of instructions. Not much different than a chore list. A program tells the computer what to do and in what order.

A basic program:

  • X = 1+2 – The computer returns the answer 3 and stores it in the variable X
  • Y = 2+3X – The computer reads the value of the X variable.  From the previous instruction we know the variable is 3, so the equation is now 2+(3*3), which the computer reduces to 2+9, which the computer reduces to 11. Now that the computer has found that the answer to the equation is 11. The computer will store the number 11 in the Y variable.

This example program has computed the answer to an algebra equation.

How does a computer make logic choices?

Computers have several different logic operations. They have the ability to check that two variables equal.  They have the ability to check if a variable is less than or greater than the other.  Computers use this kind of logic to determine which path of instructions they should follow.  A real world example of a human making a logic decision would be if laundry is done drying then take laundry out of dryer, if laundry has not finished drying leave clothes in dryer until dry.

Example:

  • if (X equals 4) do X=X+1 otherwise do X=X-1
    • this is a true or false check, X = 4 from the line above so the computer will solve X=X+1, thus X=4+1=5, if X equaled 1,2,3,5,6,7 etc then the computer would have computed X=X-1

A more complex view:

How computers actually move information around is built upon electricity.  Electricity is like water.  Electricity and water both move. Water moves through pipes and electricity moves through metal or other conductive material.  Computers have the ability to divert electricity into different paths using transistors.  Water could be diverted to different paths based upon how much pressure flows through a pipe or which gates are opened. There are other examples in nature that could create computers as well.  Computer manufactures create transistors from the element silicon (sand is silicon). They stamp small gates that tell the electricity where it can flow and where it cannot.  Using this method they create addition, subtraction, multiplication, division, logic operations and the ability to store that information. Storing information is like a light switch, in computer programming we call this binary which is a 0 or a 1. Using 0s and 1s larger numbers can be stored, and even text, pictures, music, and videos. As well as more instructions for a computer.

Security in Computers

Why is security so important?

Many systems initially are built with the idea can we do this, rather than how do we do this best.  Building a house without locks and doors could let the wrong people into our house.  Computers are much the same.  Computers are used in healthcare, and control our basic utilities like water, electricity, and even when shipments of food are sent to markets.  They also are used to design buildings and even allow us to listen to music online and talk with our friends.  They have become a part of day to day life and if we don’t secure them correctly all of the above and more could be affected by anyone in the world.

Why is security so difficult to do right?

There are many governments in the world with various levels of understanding of computer systems and cyber warfare. There are also rogue organizations of people in our country as well as other countries that might be able to launch attacks or attempt to steal secrets or leverage individuals.  Another issue is the verification problem – one person could not add in many lifetimes even close to the numbers 1 computer could add in one second.  So we are dependent on other machines to be able to verify what we know is correct, these machines themselves could be insecure or compromised.  Further there are billions of people in the world and many services and computers all communicating at different times in different ways.

This global network is constantly evolving and the complexity is such that no one person, and no one machine (that I know of) would be able to capture and effectively analyze all this information.  That doesn’t stop some from trying though.  Humans are imperfect, and they might not always secure systems effectively or have the time or ability to do so.  Computers are also imperfect, many of us would like to believe they do everything exactly right, but that is not the case, service outages, bugs introduced into the system, and systems interacting in unexpected ways and as a part of the more complex global network can all cause problems.  Like cars or any other piece of machinery it would be unwise to believe that they will work perfectly all the time. This does not mean they are not useful and can’t help us solve many complex problems. It just underscores how important cyber security is to our lives.

Imagine a system where a dam controls water to a city.  There is a set of computers that control water flows from the gates to make sure enough water gets through to power the generator.  Now imagine that someone or some entity causes the dam to stop turning and create enough water pressure that caused the dam to bust and water to destroy a city.  It is understandable we would want to keep people with packages from walking up to the dam because they might be carrying a bomb.  It is not always as easy to understand that compromising these network systems could create the same level of problem.  Even scarier these days is that even if a system wasn’t previously connected to a network, it is possible to install satellite and cellular chips that are now more accessible to the general public.  So networks that were previously protected by a firewall can be just walked around like the wall the French built in WWII.

Securing computer systems requires physical security, network security, great programming practices, secure systems where the programs are built, and other complexities such as encryption algorithms.  Scaling factors and fault tolerance also can be an issue as botnets could bankrupt cloud based companies and overload their systems.

If securing computers is so complex why do we even try?

Computers make life more convenient in many ways and can help us analyze complex data such as detecting tumors and saving lives.  In the movie Interstellar they make this point talking about MRI machines.  Computers also allow us to generate creative content and socialize with our friends around the world.  They give us access to information and libraries that were previously not accessible to certain parts of the world.  Insuring that we get that information in a secure way and they are not controlled by bad actors is paramount to their successful use.  One of the things to remember about computers is there is no 100% secure system.  We should all be careful about what information we share outside of our brains, and I am not sure even that might not be accessible in the near future, if not already.

Security is like the medical practice, just because we know bacteria could get on sterilized equipment in a certain small percentage of cases, we should still sterilize the equipment so we are optimizing the probability that something bad does not happen. Now imagine doctors trying to make sure their equipment is sterilized when a global network of people can mess with their office, where their files are, what times appointments are etc.  We can make good security choices in isolation such as using a card reader to control access to a hospital.  Making choices with many other factors becomes much more difficult.

Security can also slow down productivity, if someone is dealing with national security, time they are taking to deal with security systems could waste time if not implemented effectively.  The benefit to securing a system has to outweigh the time it takes to follow the best practices of the system.  Even as I type this there is no guarantee this will get to other users in the current form I have created it. Others could modify the words and the information and could build mistrust, or try to get people to trust systems they should not. This is why there are digital signing algorithms, a healthy mistrust of those is important as well, we should use them, rely upon that, but realize they might have been compromised.

Yet how in society do we have bridges that are built correctly and generally get through life for years? We have others that are vigilant and fighting this battle, and possibly those that prefer to leverage us will only do so when it benefits them.  Important to remember that the potential for being leveraged is high by both good and bad actors so being careful of what information is communicated on these systems can possibly save a lot of heartache.  Further it is important to remember that even though we might not be directly sending this information, others could be recording our conversation or taking our information and misusing it.  Others can take compromising pictures or leak classified documents and share them on Facebook without our permission which can damage reputations and have much greater consequences.  Sometimes the people doing this don’t have a valid grasp of social impact and the retributive damage it can do to their own lives.  Sometimes they could just be drunk frat guys that thought something was funny at the time – not trying to excuse this behavior, just hind sight is 20/20. Not quite

Important also to remember that computers are just one tool in an arsenal of many.  So they might not make the best judges, understanding mercy and being able to look at many factors might not be best left to statistics.  It would be easy to think that just because it is 99% likely that they are guilty that their case shouldn’t be reconsidered.  If those systems were insecure or leveraged at the time then they might not have made perfect judgements.  Also important to remember judges are imperfect and might not have all the information as well.  A healthy mistrust of all technology systems is important.  Just like walking across the street there is a probability I might get hurt. Doesn’t mean I shouldn’t ever walk across the street, I just should do so in the safest way possible.

Be careful of any online addiction, it is simple to be lulled into a false sense of security.  They can also be leveraged in ways you didn’t think were possible.  I was watching a lecture by Former U.S. Secretary of the Treasury Timothy F. Geithner and Professor Andrew Metrick on the global financial crisis from Standford on Coursera.  They talked about the problem being “A failure of imagination”.  To be clear this is not from a position of judgement, just trying to save some others from experiencing pain like I have in my life.

———————–

I can’t say this is the perfect way to communicate this to every person out there, I think if I had read this and taken heed of its information I could have saved myself some problems and regrets in life.

Portfolio and Useful Information

I would like to provide a portfolio of projects to showcase my work to potential employers and help others that might be interested in working on technology learn more as well.  This will hopefully be a site where others can learn about technology without being offended. I say hopefully because like all human beings I can make typos or say the wrong things in the wrong way at the wrong time. So cheers to hopefully saying the right thing and please feel free to let me know if I have a problem – in a civil manner.

Also I apologize in advance for some of the naming conventions used by the tech industry, I have failed that test at times as well.  People like to have fun with names I get it, just annoying when your entire resume starts sounding bad.  I suppose the younger we are we don’t always see how things could sound or be read into.  Not really fair for the world to do that but it does, so trying to walk that line accordingly.  What I find humorous in a bar is far different from how I want to sound making presentations and it might push people away from wanting to learn technology or other topics for that matter.  Also people with health problems can be effected in a whole different way.  Many of us haven’t experienced certain health problems so I am going to try to error on the side of caution so that others can learn here.  This is meant to be professional and creative, going to try to combine the two without compromising either.

Best Regards