QR Code using ‘zxing’ package from Google in Java

Govinda Raj
3 min readMar 16, 2018

--

These-days, QR-code has become a tech fashion. There is a reason behind that, It’s very easy to create and use it. So now let’s see how we can make our own QR-code and encrypt the real message behind the image. Before diving in programming, let’s know what’s a QR-code?

QR-code

QR Code or Quick Response Code is a two dimensional barcode that can be read by modern smartphones and special QR Code scanner devices. QR-code is nothing but image which contains some encrypted data, but how can a image contain some data????

Fair-enough, if you dig into a image creation, like how a image is created, what it is made of then you will know that a image can contain a data. So basically a digital image is made of pixel, so pixel is nothing but some co-ordinates which contains some colour value(RGB, etc). So just think that You can customise the values in RGB, also you can extract those values. So, I hope it’s clear that we can keep some data in an image and also there can be some other way by which we can store data in an image.

Now, we know what’s a QR-code! So, all good. Next question is why ‘zxing’ package?

So, According to StackOverflow , We have got two libraries- zxingandQRGen. QRGen: a simple QRCode generation api for java built on top zxing only. For now, we will go for zxing because it provides more facilities than QRGen, and zxing is also an open source project & some community still working to make it better.

Zxing Supported format

zxing provides us a way to create different-different type of encrypted formats. So we will explore ‘QR Code’ for now. Dependency can be used.

We will write a method in java to just create QR-code in specified file.

A QR code consists of black squares arranged in a square grid on a white background. There are several variants of QR codes depending on their symbol size, layout, encoding and structure. So, All-good. But got one doubt, what about security of my data? How can I secure my data?

Well, Fair-enough. QR Code itself does not provide any security. Here is what we can do instead —

  1. Before generating QR code with any text, encrypt the text using any cryptographic algorithm with a secret that only your application has access to.
  2. Generate QR Code with the encrypted text.

Now, even if someone scans your QR Code, they will get the encrypted text which they can’t decrypt unless they know the secret which was used to encrypt it. So, now all good.

QR-code

So, Please scan this QR-code, for fun.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Govinda Raj
Govinda Raj

Written by Govinda Raj

Senior Software Developer. Tech Enthusiast and love coding. My portfolio: https://govinda-raj.github.io/

Responses (1)

Write a response