Scikit Image is an image processing library in python. It is a huge collection of algorithms and available for free of cost. This library can perform a variety of complex image processing like denoising, color scheme changing, image stabilization, perspective correction, edge and contour detection, etc. There are many powerful techniques that can be using in manipulating image pixels. Being the first article in the series of image processing articles with Scikit Image, in this tutorial, we will start with the basics of changing the color spaces of images.

Color space indicates the color scheme used by that image. Most of the images are either in RGB (Red, Green, Blue) color space as in image 1 shown below.

Interesting Fact: This image called the lena is one of the standard images used for image processing since 1973 and it is a picture of Lena Söderberg, shot by photographer Dwight Hooker. This appeared in the November 1972 issue of Playboy magazine.
Source: Wikipedia

We will use this as the testing image for the rest of the tutorial. all the color schemes or scales belong to the scikit’s color package. Before we get to the color schemes, we’ll define a way to read an image with scikit.

1. Read, write and show Image using scikit

Images in scikit are in the form of numpy arrays. You can use scikit to read an image as a numpy array, apply the algorithms and write the arrays back as an image. Use the following code to read/ write an image.

from skimage.io import imread
from skimage.io import imsave
# read the image
inp_image = imread("/home/akshay/lena.png")
# replace the path above with the absolute path of the image you want to read
#write image back to file
#parameter 1: path where the image has to be saved.
#parameter 2: the array of the image.
imsave("/home/akshay/new_lena.png",inp_image)

If the image is not in the form of integer values, it cannot be saved. This happens when you apply some thresholding or manipulating functions. In such a case, you will have to first convert the image values to integer and then save it. The following code will help you do just that:

from skimage import img_as_uint
imsave("/home/akshay/new_lena.png",img_as_uint(inp_image)) #img_as_uint is the secret to correctly save images that cannot be saved directly!!

you can also see the image that you have read of just about to write by calling the imshow method as shown below:

from skimage.io import imshow, show
imshow(inp_image,'matplotlib')
show()
# the 'matplotlib' is used to tell the viewer to use matplotlib plugin while plotting the image.

Now that we know how to read, write and see images programmatically, we can start with the techniques to change color scales.

2. RGB to Gray (or Grey)

The RGB is a 3 channel color scheme with Red, Blue and Green channels whereas the Gray or Grey is a 2 channel scheme.

This technique is used as a pre-processing step in many image processing techniques like thresholding/ binarization. This is very useful when you do not need a 3 channel pixel like (120,140,30) for R, G, and B respectively but have just one value like (133) which represents the gray channel.

2. Gray (or grey) to RGB

There are cases when you have a single channel grayscale image and you want to convert into a 3 channel image, then it can be done by using the gray2rgb method of scikitImage. What you must understand is that this does not convert a grayscale image to color. that is a black and white image, remains black and white image after conversion. The only thing that changes is that, before the conversion happens, each pixel are represented as a single value, example: (120) and after conversion, it is represented in 3 channels. Example: (120,120,120). Thus, you will have an RGB image.

the images below are before and after applying the conversion. As you can see, there is no visual change.

3. RGB to HSV

HSV color space stands for Hue, Saturation, and Value. This is also called the HSI or HSB color space where ‘I’ indicates Intensity and ‘B’ indicates Brightness. The HSV color space is used a lot in the artists’ community or design community who want to understand and visually see the lighting intensity or the hue present in a given image. Some of the image processing tasks that rely on intensities need the image to be in the HSV color space. Here is how you can convert a RGB image to HSV.

4. Binarization or Thresholding

Binarization, a.k.a Thresholding refers to converting an image of any type to a binary image. Each pixel in a binary can be either black (0) or white(1). It is important to note that for binarizing an image, the image should be in grayscale first. So we start with a RGB image and then we convert it to grayscale before applying the thresholding to it.

You might have observed that while saving the image, we are using the “img_as_uint” method to save the thresholded image. This is done because, when the image has been binarized, it is in the form of non-integer values and thus cannot be saved. So by using the “img_as_uint” we are converting the image values to unsigned integers which can then be saved by scikitImage.

Following image shows the effect of applying the OTSU_thresholding on the image. Thresholding is used for many image based solutions like Optical Character Recognition, template recognition, etc.

An extraordinary tale of Krishna and the prophecy that he had to fulfill. I remember my grandparents telling me bits and pieces of Krishna’s and Balaram’s adventures but I had never got the full story up until now when I got a chance to read this book.

It is beautifully written offering a second, more realistic perspective to the other magical versions of this same story. This book took me straight to that era where Krishna was born and I could easily imagine and experience their life, their surrounding, their difficulties with vividity. This is one of those books where you know that certain events would happen but it wouldn’t change the excitement of getting to read those parts nonetheless.

The description of historical places like Gokul, Vrindavan, Mathura with their lush landscapes, palaces and the lives of people are breathtaking. I felt as if I was transported back in time to those places living with those people.

The book is written in a simplistic yet gripping style. I recommend it to anyone who wants to forget everything temporarily and go on an incredible adventure with Krishna and Balaram.

An enthralling book with a gripping storyline. Once I had started reading it, I couldn’t get myself to stop. The book teleported me straight to Soldier Island, the place where the story is set.

With multiple murders happening on the island, The reader’s mind races to conclude who the killer could be. Each conclusion made will be proved false soon after. It’s an amazing book written in a way where the events are presented as it is so the reader can make deductions. Vivid descriptions of the events and the surrounding give the reader’s imagination fuel to visualize the eerie surrounding and the morose atmosphere. The thoughts running through the minds of people on the island builds the suspense and tension.

The characters in the story are very well picked. We get to experience each one of them trying to best utilize their skill just to survive. Their instincts of self-preservation are completely based on their experiences in their chosen field of work. Whether it’s the doctor, the policeman, the army man or the judge, each one of their contribution to keeping everyone alive is noteworthy.

Murder mysteries have always fascinated me and this one is truly a masterpiece. I can very well relate to the author when she says ” I know how hard it was to write this book”. There are innumerable things that had to be set right for this story to be woven out perfectly and that is exactly what has been done. Loved this book from the start to the end.

A brilliant book that talks about the working of our conscious and subconscious mind. I loved the analogy of the ant being the conscious mind and the elephant being the subconscious mind as it describes in clarity the potential that we have as humans.

This book is written as a story of an ant and an elephant in a desert with a wise teacher preaching the ant to learn and work with the elephant, guiding it in the process. I loved the simple way in which the author has conveyed the 5 important steps to tune and work with both your minds to reach your goals and become a better leader. The things to learn from it are direct and each lesson is accompanied by the excitement, hard work, and frustrations that we face in daily life and how we can apply the teachings to change our way of thinking and handle situations in a better way.

I felt as if is this book was written for me because the situations and reasoning were exactly what I was facing or had faced before ( turns out, a lot of people feel that this book was specifically written with them in mind) and it showed what I was doing wrong. I could experience changes early on by applying the steps mentioned in the book. Anyone reading this book will have at least one new thing to learn from.

Two quotes I liked the most in this book:
1) Gratitude is the magic ingredient in the recipe for a fulfilling life.
2) No two thoughts can occupy the mind at the same time ( think about something positive when negative thoughts come to your mind)

When I read that this was a sci-fi book about the galaxy and beyond, it immediately caught my attention. I started reading it and I loved it. It combines two genres ( sci-fi and comedy) seamlessly to bring out a wonderful story of these few people from various galaxies who embark on an adventure around the universe.

This is a book about a book. “The hitchhiker’s guide to the galaxy” is a guide/book that helps space travelers to survive and know about new planets/ start or a solar system, and how to travel throughout the universe. The best thing about this book is the ability to bring out perspective on how a far more advanced life form than ours in the universe can still have the same mentality of people we meet or see every day and what kind of chaos it can create.

Humour is present everywhere. Right from the way different life forms are portrayed to giving consciousness to robots, it’s hilarious ( I just love Marvin.. he’s funny in his own depressed ways). Some of the scientific explanation of what we feel as impossible things are hysterical. I thoroughly enjoyed reading this book.

So, these were the 4 books I recently finished reading and all of them were awesome. Share your thoughts and recommendations in the comments below.

I have started to read a lot and I figured that I could share what I read with others who might find this as a useful recommendation tool. If you have read books that are similar to these, you might recommend them to me as well.

This article is the first in the series and I review the following books:

A phenomenal non-religious book on mysticism, yoga, well-being, inner peace, and more. It has been structured in two parts. The first part is devoted to making the reader understand the various processes in yoga and debunk myths. It also introduces readers to various dimensions and the non-physical experiences that are unknown to many. The second part of the book deals with the various aspects of what life is and gives numerous exercises and practical experiments for the readers to try and have a glimpse of “out-of-this-world” experiences.

There are a few things that I absolutely love about this book. Firstly, the way in which Sadhguru has explained some of the simplest things in life makes you understand its profound impact and makes you realize that perspectives can make an insignificant routine to a life changing experience. Secondly, this book steers far away from any religion, beautifully explaining its difference with spirituality. Thirdly, unlike most of the books, it does not stop at giving you hopes of the so-called “unrealistic expectations”. The author repeatedly asks the reader to experiment with what has been conveyed and gain the knowledge of peace, well-being and out of the body sensations through an experiential process. Finally, the anecdotes in this book are amazing. Some are witty, some are to the point, but all of them successfully convey the intended message to the reader.

I thoroughly enjoyed this book and learned a lot from it. It is not a manual to bliss and harmony but a catalog of what is possible. There aren’t any step-wise procedures but that is something the reader is expected to explore, experiment and seek post reading the book.

Best quote from the book: “Yoga is not about being superhuman; it is about realizing that being human is super.”

This book is a collection of articles about Rahul Dravid, written in a span of over a decade. These articles sum up Rahul’s life as a cricketer(mostly), as a person, and as a family man from many different people’s perspective. It is like a small window to this great achiever’s life and I got to learn a lot of things from him (indirectly of course).

His Determination, hardworking nature, strength to withstand dark moments, and most importantly his humility has been elaborated by many people who got a chance to know him. For the cricket lovers, some of these articles get technical about the game and it’s an enjoyable experience to read his stats.

The last article in this book is the speech given by Rahul at the Sir Donald Brandman Oration and I feel this could have been the best way to end this book. It’s a brilliant speech that shows his passion and concern towards cricket and also the hope of better days in the future for some forms of the game.

This is a well-written biography. I always wanted to know about the man trying to change the world, and this book gave me an unbiased view on Elon and his companies. I got a complete picture of things that go behind building multiple companies that have the potential to disrupt industries. It beautifully reveals the struggle, the dedication, the drive, and ruthlessness that exists within Elon and how he uses them to his advantage, even when the whole world is against him.

One other thing I had always wondered was, how it would be working with him and this book, I found a pattern with the people working with him, what he expects from them and what they think of him. the author has interviewed many people working with him right from the top to the bottom and you can see the consistency in the employees’ drive and motivation to change the world ( not all the employees, however).

The best part about this book is that it isn’t written to glorify him, but to give an account of what he has done and how he did it. We have to analyze those facts to see if Elon is actually the person we think he Is. This is truly a journalistic masterpiece.

I would recommend this book to anyone interested in entrepreneurship, technology or clean energy.

This book is written in a very unique style, the whole story is conveyed through letters written to the Chinese Premier ( why specifically him, I couldn’t figure out, probably it was some inner urge he had to get his story out and share his secret one way or another)

It’s a story about a guy from a village in north India and his transformation that occurs when he becomes a driver to a wealthy man in Delhi. The story is definitely gripping and you will always be left wanting to know more about him and why he became a murderer.

The story, however, has been told in an extremely negative mindset about India from corruption to filth to poverty and makes India look like a completely chaotic place with no hope. Well, though most of it might be true, it’s not the only thing that happens. Irrespective of where you are, India has a lot to offer. you can find more good than bad unlike how it has been portrayed in this book. I would have rated this book higher if it weren’t for this negative look on India.

In the world of technology, we often tend to think that our life is made simpler and our capability to do things more efficiently has been made possible. However, like our inherent human tendency, we abuse the power we have been given and completely ignore the possibilities of side effects.

Does technology have any side effects? Well, there are many which you might not be aware of but through this post, I will try to answer this fundamental question and hopefully help make your life a little better.

To begin with, answer the following questions to evaluate where you stand now:

Do you find yourself sleep deprived irrespective of the number of hours you have slept for? or are you waking up each morning wondering why you aren’t feeling fresh?

Do you experience headaches frequently? Do these headaches last for hours together?

If your answer to both were yes, then this article will give you more information on why that might be happening and suggest slight adjustments that you can make in your routine and try to mitigate the side effects.

If your answer was no for the questions above, then you are doing something right and this article will tell you what that is.

The Normalcy

Before we go about the issues, I would like to dive into the science of what happens normally in a human body and how it happens.I will try to keep these explanations as simple as possible.

1. Circadian Rhythm a.k.a The Biological Clock

The Circadian Rhythm is a cyclic process in your body responsible for controlling various internal processes like maintaining your sleep cycle, blood pressure, secreting hormones at the right time, regulating bowel movements, and many many more things. This happens every day.

Though this cycle has a set of tasks to perform at a given point in time, it is very flexible and can be influenced by the person’s surrounding environment. This is a good thing because it adapts to the natural changes like seasonal changes, light, and temperature without affecting you. However, this also means that leading an unhealthy lifestyle can heavily influence this cycle and throw it off balance causing many issues to you.

2. Eyesight

The reason why we have the ability of sight is relatively unknown. To understand this, we would have to first understand what light is. To put it in simple terms, light is a wave of energetic particles. In this wave, only a small portion is visible to the human eye and this visible portion is responsible for our visual perception.

in the diagram above, the left-hand side depicts lower energy particles and rightmost side indicates higher energy particles. The ultraviolet light comprises of high energetic particles that are bad for humans. Fortunately for us, most of it is filtered out when the light from the sun travels through the earth’s atmosphere.

When the rest of the visible light passes through your eye, many different things happen. Firstly, as the objects around you reflect the light, your brain forms the image of your surrounding by processing in this information. Depending on the energy of the reflected light that falls in your eyes, it will identify and differentiate the various colors and you will be able to see.

However, the energy of the light particles that falls through your eyes is used by the brain to determine a few other things. For example, in the visible range, the blue light corresponds to higher energy particles, and when this light falls through your eyes, your brain interprets that it’s morning time and starts to trigger various chemical processes in your body.

3. The Sleep Cycle

Your biological clock responds to external stimuli to trigger the sleep process. The most influential external stimulus is light. When sunlight fades and it starts to get dark, the amount of light going through your eyes reduces drastically and the body starts to generate a sleep hormone called Melatonin. When this hormone is released in large quantities in the blood ( usually in the night), you tend to relax and start feeling sleepy.

When you wake up the next morning, the sunlight pours in through your eyes and the body gets the signal that it’s daytime. It has now been observed that the “blue light” which is a part of the sunlight is heavily responsible for suppressing melatonin. With the receding levels of this hormone in your body, you feel fresh and ready to start your day. This process happens day after day for your whole life.

Melatonin can also be absorbed by the body from certain types of vegetables and fruits like tomatoes, walnuts, olives, rice, etc and you may start to feel relaxed. When the time comes for the body to secrete this hormone, it generates the right amount required for a good sleep.

The Smartphone

In this section, I will try to simplify how the smartphone display works. Though this process is similar to almost all the digital devices, I want to focus more on smartphones as they are the most used device by people these days and are also the cause for the current technology-driven lifestyle.

Most of the smartphones today have LED screens. This screen is made up of a set of LED light bulbs and a few layers above it. These layers are made of various materials to filter light as it reaches to the top where the user can see.

High Energy light – The Blue Light, which we have seen earlier are high energy particles in the visible range are used. This makes the screen appear much brighter so that you can easily see it when you are outside. The high energy of the blue light particle makes it the perfect choice to beat the sunlight and make the phone display stand out even in bright places.

The result of this is the bright, crisp high definition screen that makes anything on it look amazing any time of the day. This is truly an engineering marvel.

Piecing Things Together

Now that we know how our body works normally and how a smartphone display would work, we can piece these two together to understand the side effects of using a smartphone throughout the day.

1. The Day Time

During the daytime, there is not much of a difference in terms of the light from the screen affecting you on a short term basis. Mainly because the light emitted by the smartphone has similar traits when compared to sunlight. However, since we are constantly looking at screens for a prolonged period of time during the day, the high energy particles cause flickering in the eyes leading to eye strains. This, in turn, causes loss of clarity, headache, mental fatigue, to name a few.

2. The Night Time

The most destructive effect of smartphone screens happens at night. Consider this normal behavior of an average person living in a town/ city.

He or she returns home in the evening after staring at computer monitors/ mobile phones for a prolonged amount of time. At this point of time, the body senses that it’s dark due to the absence of sunlight and starts to produce melatonin in the body. The person starts to feel relaxed and once the chores are done, the person picks up the smartphone to check WhatsApp, to watch an episode of a series on YouTube and checks mail. At this point of time, the person does not realize what’s happening inside the body.

Inside the body of that person, melatonin, the sleep hormone is being secreted, but as the bright blue light from the smartphone enters the eyes, the brain gets a signal and it starts interpreting that it’s day time. And since the biological clock is influenced by your surrounding, it starts to suppress the melatonin and instead of becoming more and more relaxed, you start to become more and more alert. Suddenly you find yourself thinking, that you aren’t feeling sleepy anymore and you continue to use your mobile for some more time. It’s a vicious cycle.

So, What are the Side Effects?

As you might have guessed by now, this habit of yours is suppressing the amount of melatonin required for a good sleep. This answers the first question that we had asked, why do we find ourselves sleep deprived irrespective of the number of hours we have slept for? and why we aren’t fresh when we wake up. When you do not get a good sleep, that triggers another set of problems like headaches throughout the day, feeling lethargic and having mental and physical fatigue and in some cases, this habit leads to insomnia.

Another side effect that arises from staring at the bright blue light in a dark place is eye strain. The Bright light which has high energy can strain your eyes causing headaches and loss of clear vision.

Different Ways to Prevent It

The side effects can be prevented to a great extent and following some of these prevention techniques can help you feel better within a day. Now, the most obvious thing to do would be to reduce the usage of the smartphone. If you can do this, then hats off to you. However, most of us might find this to be a very challenging task. So, for people like you and me, here are a few simple things you can try out for various screen types:

Use the screen in low brightness from evening onwards.

For your desktop/ laptop screen, there is a software called Flux. This software works by making your screen slightly orange depending on the time of the day. orange light falls in the low energy particle side of the visible spectrum, thereby reducing damage to your eyes.

Most Important Step: Practicing this step can quickly show you the results and so it’s important that you do this every single day. DO NOT use smartphones or any digital device 1.5 to 2 hours before you sleep. Make sure you finish checking your emails, WhatsApp and other important things at least 1.5 hours before you sleep. Set your alarms and leave the phone aside. You can use the time you have till you fall asleep to go for a walk, talk to your family members or best, spend time reading a good book.

I hope that this has given you a bit more understanding of the aspects of smartphones and human processes and I hope that this information helps you.

P.S: share your views on the effects of smartphones, how it has helped you or how it hasn’t in the comments below. If you find this article informative, share it with others so that they can benefit from this as well.

Thank you for being a part of my journey. Over the years, this blog has tried to become a destination for useful resources in the technological space.I have put my heart and soul into some of the things I have shared here and I have always wanted to make this big.

Among the tens of thousands of readers that this blog has witnessed, I know for a fact that many have found the information present here to be very useful. It makes me feel good that I had a part to play in helping a few people in their respective journeys. I do not exactly know how many are constantly following this blog, but if you are one among them, I thank you for your support. I wouldn’t have a good blog without you.

To share with you a brief history of this blog, I would have to go back a couple of years when I had felt that I could share the things that I come across with other people with a hope to help them in some way. As time went by, the readership grew and so did the type of blog posts. I primarily blogged about a few niche technologies like python, Raspberry Pi, and Ubuntu. This blog has helped me in various ways which I hadn’t realized before. One example for this is the way in which I was able to leverage these content to get freelance writing projects. However, the times when I was not fascinated by a few technologies or when I got caught up with work, I wouldn’t blog and months of dry spells would follow. I sometimes felt that the drive to keep this alive was missing.

Writing and science have been two of my passions but this blog focused more on technology which as you know is a by-product of science. I want to change this now and start giving more importance to science as well. You might have subscribed to this blog for the type of technical content I have been writing so far and so it is important that you know what is coming up next from my side. I have decided to publish science-based articles that dwell deep into the intertwining of science with technology in a bid to simplify some of the complex concepts or bring out some of the research work that can benefit common people like you and me.

To begin with, I will publish articles only when I am satisfied with it and not on a regular basis just to maintain a cyclical publishing habit. As time goes, I might shift to a fixed pattern. I would, however, need your support in terms of sharing the content and helping more people understand and gain more knowledge. I don’t want to consider this as a new year’s resolution but as a new attempt in pursuing my passion and giving this blog a part of my identity.

Happy holidays!! I hope to see you soon.

Akshay.

P.S: please do share your opinions and suggestions through the comments. It helps me as a blogger to understand what you feel and also improve myself. So, go ahead, let me know 🙂

The Udemy Sale is back with huge discounts.Sitewide-15dollars is now live. You can get even courses worth $200 just for $15 . this sale will last only for 3 days so make sure you grab the courses you love!!

Steps to get your favorite course for up to 95% discount and in some cases for free:
1) narrow down on the topic you want to learn.
2) Click the sale link Here and login
3) That’s it. All courses from $50 to $200 will be up for only $15.
4) Also look out for a few courses that are free for the sale duration. just sort the search result by price to free.

Following are some of the best selling courses designed to make you a pro:

Making a Raspberry Pi cluster requires an initial setup to be performed. Here I assume that the OS that is running is Raspbian. So once the cluster is built generally one Raspberry pi designated as the master node controls the functionality of all the other nodes. So this post deals with how the master node connects to or other nodes ,how you can use the master node to login to any other node in the cluster, how to assign static IP address and how to differentiate each of the nodes from the other by assigning different hostnames.

Assigning static IP address :

The first thing that has to be done is assign static IP address to each PI . This helps to connect to other PIs(nodes) via SSH (Secure Shell) . So first use the command :

ifconfig

This lists all the IP addresses. My result of running the command ifconfig was :

inet addr: 192.168.3.2 bcast addr: 192.168.3.255 mask:255.255.255.0

Make a note of these addresses. So, from the above result, the inet address indicates the IP address of the node. What we do now is assign addresses to each node. The first step in it is to decide a range of IPs . I had 5 nodes and so I decided to take the range 192.168.3.215 to 192.168.3.219 . Once the range is fixed login to one of the PIs.
Also, make a note of the gateway address by typing the following command

One last thing that needs to be modified is the /etc/resolv.conf file. This file contains information of DNS name resolvers that allow your raspberry pi to resolve names to IP addresses. For example, if you ping http://sourcedexter.com, the raspberry pi will have to determine the IP address of my python tutorials website,

Enter the following command to edit the resolv.conf file:

sudo nano /etc/resolv.conf

Enter the follow Google public DNServer IP address:

nameserver 8.8.8.8
nameserver 8.8.4.4

Press CTRL-X to exit but remember to save the file by accepting the changes.

Now type ifconfig and the new IP will be the one you would have assigned.Repeat this for all the other nodes on the cluster individually.

Change the hostname manually

If SSH is not installed then the hostname can be changed manually by logging into each of the raspberry pi individually and changing the hostname file as :

sudo nano /etc/hostname

By default the content of the file is :

pi

change it to what you want. for example, if the new hostname should be client003 , then delete the existing name and type the new name :
client003
press CTRL+X followed by Y to save and exit. So from the next time you login the new hostname will be seen.

1 Introduction

Encryption is the process of encoding messages or information in such a way that only authorized parties can read them. With almost no privacy in this digital generation of our’s, encryption of our data is one of the most required tools. Most of the applications like Gmail encrypt our data, but the data on your system is still unsecured and there are hackers or unauthorised users waiting to access them.

When you are building many other applications using various Linux based devices, you still have to take care of the data on it. One way to minimize the risk of data theft is to encrypt the data that is present even on our local system.

Now there is another very interesting topic called steganography. This involves hiding data. The key difference between encryption and steganography is that, in encryption, you know there is data but you cannot make any sense out of it. And decryption is the only way you can read the actual data. However, in steganography, you won’t even know that the data actually exists. it’s hidden in plain sight. You can easily build your own steganography tool in python.

This tutorial demonstrates several methods of encrypting the data on Linux systems using command line tools.

2 Encryption using GPG

2.1 GPG Introduction

GPG stands for GNU Private Guard which is a command line utility that is used to encrypt and decrypt data files or folders using either symmetric or public key encryption. GPG is a GPL Licensed alternative to the PGP cryptographic software suite. GPG is used by OpenPGP-compliant systems as well.

2.2 Encryption using Symmetric Key

Here I have a file named “test.txt” that I will encrypt and then decrypt with a symmetric key and print the decrypted text into another file called “output.txt”.

Run the following command to encrypt the file test.txt using a symmetric key. The option “-c” indicated the GPG to use symmetric keys.

gpg -c test.txt

The result of this will look like the image below. The first time when GPG is run, a .gnupg folder is created. It contains the files that are necessary for the encryption process. It then asks you to enter a passphrase twice. Please make sure that you enter a strong passphrase and that you remember it as you need this in future to decrypt your files.

So, once the passphrase is entered correctly, a file called “test.txt.gpg” is created. This is the encrypted file. The following image shows the file before and after encryption.You can see that the encrypted text is in an unreadable format.

Use the following command to decrypt the encrypted file

gpg -o output.txt test.txt.gpg

You will be prompted to enter the passphrase used to encrypt. Once you enter that correctly, “output.txt” file will be created with the same contents as that of “test.txt”. The output of decryption might look similar to the image below:

2.3 Public Key Encryption

Here we will encrypt a set of files using the public / private key encryption mechanism of GPG. It involves creation of a private key which should never be shared with anyone and a public key that has to be shared with the people who want to send you encrypted data. Public key cryptography is a very interesting topic. You can read about it in detail here.

First, we will have to pack the files into a compressed folder. Here I have a directory called “enctest”with three files test1.txt to test3.txt .We will compress this directory tar.gz file. I wll use the following command to create the compressed tar.gz archive:

tar czf files.tar.gz ~/enctest

This creates a file “files.tar.gz” . We now have to generate the public/private key pair. Run the following command to generate the key:

gpg –gen-key

Remember, this has to be done only once and any number of files and folders can be encrypted with this key. Once you type this command, various set of questions will be asked. The questions will be:

What kind of encryption to use? I selected 1 which is RSA and RSA.

What should be the key size? I chose 2048, you can choose any size in the range of 1024 and 4096.

When should the Key expire? I selected 0 , which means that the key never expires. But can provide days, weeks or years if you want it to expire in a particular time.

Other things like passphrase will be asked, you will be prompted to enter it twice. Make sure you use a strong one and that you remember the passphrase. Also your credentials will be used. The credentials that I have used here (provided below) are just for testing. It is recommended that you use your genuine credentials like name, email ID and provide some comment.

The following content shows my answer and how the output will be:

gpg (GnuPG) 1.4.16; Copyright (C) 2013 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 2048
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
= key expires in n days
w = key expires in n weeks
m = key expires in n months
y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: John Doe
Email address: johndoe@somemail.com
Comment: tis is key generation
You selected this USER-ID:
"John Doe (tis is key generation) <johndoe@somemail.com>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.

Once you enter the passphrase, it begins to generate the key. It will ask you to do some work. It is recommended to move the mouse or type something or use the drives to open some files. It will use this work to generate random bits. You may have to do this multiple times. The output for me is shown below:

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 187 more bytes)
+++++
...+++++
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 92 more bytes)
.....+++++
Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 114 more bytes)
+++++

Once done, the key has been generated. It will look similar to the content below:

Here the file “file-enc-privkey.asc” will hold the backup of the private key safely. Once exporting and key backup is complete, we can now encrypt and decrypt the .tar.gz file. Use the following command to encrypt:

gpg –encrypt –recipient ‘John Doe’ files.tar.gz

Remember to change ‘John Doe’ in the above command to the name given by you during key generation, else the encryption will fail. When the command runs successfully, an encrypted file called “files.tar.gz.gpg” will be created.

Now we can decrypt the tar.gz archive using the following command. It will use the private key along with the passphrase to decrypt and provide the decrypted folder. Use the following command to decrypt:

gpg –output output.tar.gz –decrypt files.tar.gz.gpg

The above command will ask for the passphrase and then decrypt the encrypted file and create a compressed file named “output.tar.gz” which can then be extracted to folder with tar to get back the files. The following image shows the output of encrypting and decrypting commands:

2.4 Why GPG?

GPG supports both: public key encryption and symmetric encryption and this provides a good amount of flexibility and can be used for a wide range of applications. There isn’t a need to provide any kind of sensitive information and also gpg can have any number of encryptors by using the public key. Choice is given to the user to select from multiple encryption algorithms. These reasons make it a very useful security tool to for encryption of files and folders or data.

Interested in Security, there is no better way to learn than knowing how to breach security: Learn from experts on ethical hacking and how people and data can be manipulated to gain unauthorised access to private data :

3 Encryption using OpenSSL

3.1 Introduction to OpenSSL

The OpenSSL project is a collaborative effort to develop a robust, commercial-grade, full-featured and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS) protocols as well as a full-strength general purpose cryptographic library. OpenSSL is available for most Unix-like operating systems and it is based on SSLeay. OpenSSL supports also many SSH, SFTP, and SCP applications. Here we use OpenSSL to encrypt data by making use the asymmetric encryption and the AES cipher. Symmetric encryption can be used for encrypting bigger files or data.

3.2 Generating the Public and Private keys

The first thing we have to do is generate the public and private keys.We first generate the private key. To do so, use the following command:

openssl genrsa -out private_key.pem 1024

The above command instructs OpenSSL to use RSA to generate a private key with a size of 1024 bytes. The key is then stored securely within a file called “private_key.pem”. The output of this command will look similar to the image below:

Once the private (the secret) key is generated, we can use that to generate the public key so that they form a pair. Use the following command to generate the public key:

In the process of building a Raspberry Pi cluster, I came across a few libraries for inter-node communication. I was facing some issues while using these libraries and the errors weren’t one of the common ones associated with Raspberry Pis. These libraries made use of a feature called Hard Floating Point computation and I wanted to know if my Raspberry PI supported it. So, this article is my understanding of ARM chips and its variants and how it all fits my cluster built using a Raspberry Pi.

ARM chips which are based on the RISC (Reduced Instruction Set Computer) architecture were developed by a British company called ARM Holdings. Since RISC allows components to be very small in size and lesser in number, you can find that the ARM chips are very small themselves and they don’t require any external cooling. This is the main reason for most of the smartphones today to have ARM chips in them.

ARM releases these chips in various versions . Among all of them, till ARM V7, all chips supported only 32-bit architecture. But from ARM V8 onward, support was provided for 64-bit architecture as well. The major advantage of these chips is that it supports efficient multi-core computing and high core counts at lower costs.

Raspberry pi Model B supports multiple nodes to be connected and used in parallel. To achieve this, two variations of ARM chips can be used. One is the ARMEL (ARM little endian) and the second ARMHF (Hard Floating) . ARMEL is used for soft floating points where the computation is restricted only to a certain level of floating point numbers but ARMHF, on the other hand, is a hard floating point architecture , giving more support to high floating point number computations during parallel computing. The raspberry Pi comes with a support for ARMHF which is available for use through various ports provided by Raspbian (the Debian OS for raspberry Pi).

MPICH2 is a very good message passing library that makes parallel processing on a Pi possible but has packages only for ARMEL architecture. So, it’s wiser to use MPICH tools and build it within the raspberry Pi and utilize the ARMHF.

The Pi Model B has an ARM11 family of chips inside it. The ARM11 is based on the ARM V6 and is hence 32-bit architecture. This chip has a clock speed of 700 to 750 MHz but can be overclocked to 800 Mhz without a void in warranty. But the full overclocked speed is around 1 GHz. The CPU, the GPU, and the RAM are on the same chip. The CPU has a speed of 65 GFLOPS and the GPU of about 24 GFLOPS and a 512 Mb RAM.

Overall, it’s a very efficient chip having power equivalent to a Pentium 2 processor and contributes greatly to the small size and low cost of the raspberry pi.

You can now learn to build cool applications with Raspberry Pis. Sign up and get the best resources to get started: Login to get the Course for $10

Django is a Python web framework. It helps you rapidly build high performance and efficient web applications. It’s very much liked by the developer community because of some of its amazing features like template system , URL design , etc. Django supports both Python 2.7.x and Python 3.x . Some of the famous web applications built using Django are :

Instagram – A photo sharing app for android and IOS.

Matplotlib – A powerful python 2D plotting library.

Pinterest – a virtual pin board to share things you find on the web

Mozilla – creators of firefox ,browser and OS.

And many many more. This encouraged me to start learning Django and try building my own web application. But when I started searching for resources . I found it difficult as a beginner to find and install what I needed to get it up and running.

I was confused because of the verity of choices I that was there to install and set it up. But after a lot of searching and experimenting, I found one straightforward method , which is good enough for a beginner.

It’s important you know how to program in python so that it helps you to build awesome applications quickly. There are a lot of amazing free courses to learn python that you can make use of.

So, Here are the steps to install it.

1 Installing Python

The first step is to install python. Generally most linux OS have python 2.7 installed by default. To check if it exists, use the following command:

python --version

you may get an output similar to

Python 2.7.6

or any other version installed. If not, then, it can be downloaded from HERE.

2 Installing a database system (SQLite)

Since most of the web applications need a database and querying has to be done upon it, it’s better to have a database setup on your system. Django provides the usage of database engines like PostgreSQL, MySQL, SQLite, Oracle. Its very simple to learn using a DB with python. Knowing this gives you an added advantage in landing your next high paying job.

SQLite is a database we can use, it is a light weight database and its good enough to begin with. For any simple web applications that you develop, you can use SQLite itself and later upgrade it to suit your needs. So, to install SQLite, use the following command:

sudo apt-get install sqlite

Please do note that in some linux systems SQLite is preinstalled along with python, in such cases, the above command can be ignored.

3 Installing pip and easy_install

Any previous versions of Django if existing has to be removed. But if you have pip or easy_install for installation then you don’t have to worry about removing the previous versions because the pip or easy_install will do it for you. So, install both of them by using the commands:

sudo apt-get install python-setuptools

The above command installs the required python setup tools along with easy_install. Most of the cases, “pip” is preinstalled. If in any case it isn’t, install pip as given in the official documentations HERE.

Before proceeding, confirm that python, SQLite, pip and easy_install has been installed. To do so, use the commands one after another given in the image below and the output of each command should be similar(not same) as shown in the image below.

4 Installing a virtual environment

In this step, we install a “Virtual Environment.” After a lot of searching and testing, I found that Django can be run very easily on a virtual environment. A virtual environment is created to encapsulate all the data and resources required to run Django at one place so that all the changes made remain in that environment itself. Another important benefit of the virtual environment is that it supports the light weight web server provided by Django by default. This allows the installation and integration of apache server to be avoided.

One of the easiest way to install virtual environment on linux is by using the “easy_install” command. This script comes with a package called python-setuptools which we have installed in a previous step. So now, we can install the environment using the following command:

sudo easy_install virtualenv

Be patient, as it may take some time depending on the speed of the internet. When finished, the terminal output should be similar to the image below.

5 Creating and setting up the virtual environment

Now we create a folder using virtualenv so that the folder can act as the virtual environment to contain Django. Type the following command in the terminal:

virtualenv --no-site-packages django-user

Here django-user is the folder that will be created and used as the environment. It will be created under the directory you are currently in. Now to start the environment use the command:

source django-user/bin/activate

Now if you see your folder name

(django-user)

at the beginning of the prompt , it means that the environment is started. Refer to the image below.

Navigate to the folder django-user using the command.

cd django-user

Upon listing the items in the folder using the “ls” command, you will be able to see directories like bin, lib, include, local. So what this virtual environment does is that any command or operation performed in the environment will not affect anything outside the environment. So the changes are isolated and this allows us to easily create as many environments as we want and test many things very easily.
<h2 id=”-installing-the-django-framework”>6 Installing the Django framework</h2>
The final step is installing Django within this environment that we have created in the previous step. Remember that you still have to be in the virtual environment in the django-user folder else django will be installed outside the environmant and cannot be used. To install Django use the command:

easy_install django

As a reference, view the following image. Note that the beginning of the prompt says (django-user) which means that you are currently in the virtual environment and before installing django, you should be within the “django-user” directory. This is very important.

Thats it! Django is installed on your system with all required functionality for beginners to develop and learn the framework. Now you can go ahead and try out the DJANGO tutorial to learn the different functionalities and run your first web app. You can find the tutorial in the official Django documentation HERE.

Learn from the best in the market, Use this offer to get all courses for $10 on Udemy.