File Encryption and Decryption using RSA in Java

Use RSA for File Encryption and Decryption in Java

“If you can’t do anything about it, laugh like hell.”
― David Cook

1. Introduction

RSA (Rivest–Shamir–Adleman) is an asymmetric encryption algorithm widely used in public-key cryptography today. The word asymmetric denotes the use of a pair of keys for encryption – a public key and a private key. When data is encrypted by one key, it can only be decrypted using the other key. The public key is publicized and the private key is kept secret.

Continue reading “File Encryption and Decryption using RSA in Java”

How to Use AES for Encryption and Decryption in Java

Learn how to use AES for encryption and decryption in Java

“There’s as many atoms in a single molecule of your DNA as there are stars in the typical galaxy. We are, each of us, a little universe.” ― Neil deGrasse Tyson, Cosmos

1. Introduction

The Advanced Encryption Standard (AES) is a standard for encryption and decryption that has been approved by the U.S. NIST (National Institute of Standards and Technology) in 2001. It is more secure than the previous encryption standard DES (Data Encryption Standard) and 3DES (Triple-DES). You should be using AES for all symmetric encryption needs in preference to DES and 3DES (which are now deprecated).

Continue reading “How to Use AES for Encryption and Decryption in Java”

JDBC – More About Columns in an SQL Query

Learn how to get details of columns in an SQL query with JDBC.

1. Introduction

An earlier article covered the basics of JDBC (Java DataBase Connectivity) and how to perform SQL queries on a MySQL database. Frequently, it is useful to obtain more information about the columns in a query. These include: the number of columns, column names and types, etc. Maybe you want to build a GUI table showing the results of a query, which requires the names of the columns and more. This article will show you how to retrive the information using JDBC.

Continue reading “JDBC – More About Columns in an SQL Query”

JDBC MySQL Tutorial

A simple tutorial showing the basics of using JDBC database API.

“A man’s true character comes out when he’s drunk.”
― Charlie Chaplin

1. Introduction

JDBC stands for Java DataBase Connectivity and is the standard API (application programming interface) java provides for working with databases. JDBC, as a standard, is built into the java platform. To connect with and use a database, you need an additional component called a jdbc driver, which is specific to the type of database you are working with, such as MySQL, SQL Server, etc. In other words, the JDBC API consists of a small number of classes and a bunch of interfaces, the implementation provided by the actual database vendor. This is illustrated by the figure below.

Continue reading “JDBC MySQL Tutorial”

Java – Zip Folder Tutorial

Learn how to zip a folder in Java

“Quotation, n: The act of repeating erroneously the words of another.”
― Ambrose Bierce, The Unabridged Devil’s Dictionary

1. Introduction

Java provides good support for reading and writing zip files. In this article, let us learn how to create a zip file from the contents of a folder in java.

Continue reading “Java – Zip Folder Tutorial”

Java Calendar Examples

A Tutorial covering the basics of Java Calendar and Date Manipulation

“Let us tenderly and kindly cherish therefore, the means of knowledge. Let us dare to read, think, speak, and write .”
― John Adams

1. Introduction

Java provides a Calendar class for performing data manipulation. A closely related class is the Date class, used to represent a specific instant in time starting from epoch (January 1, 1970 00:00:00.000 GMT). Let use learn how we can use these two classes for date and time manipulation.

Continue reading “Java Calendar Examples”

Java Number Conversion

Learn the intricacies of Java Number to String Conversion and vice-versa.

“It is a good thing for an uneducated man to read books of quotations.”
― Winston S. Churchill

1. Introduction

Number conversion is a frequent need while programming. You may have a need to convert from a hex string, decimal string or octal string. Or maybe you are using a number from a different base. The reverse conversion is also required many times: converting from a decimal integer to hex string, octal string, etc. Let us see how we can do these conversions.

Continue reading “Java Number Conversion”

Java Path API Tutorial

Learn the intricacies of using the Java Path API in this tutorial

“The mind is not a vessel to be filled, but a fire to be kindled.”
― Plutarch

1. Introduction

The Java Path API is a new introduction starting from version 1.7. It provides convenience methods for manipulating file paths in a system-independent way. Let us examine the usage of the Path API in more detail.

Continue reading “Java Path API Tutorial”

Java – Reading a Large File Efficiently

Efficiently read text and binary files in Java

“The world is a book and those who do not travel read only one page.”
― Augustine of Hippo

1. Introduction

What’s the most efficient and easiest way to read a large file in java? Well, one way is to read the whole file at once into memory. Let us examine some issues that arise when doing so.

Continue reading “Java – Reading a Large File Efficiently”

Java ThreadLocal – Proper Usage

Learn how to properly create and use ThreadLocal to share data between threads.

“A lie gets halfway around the world before the truth has a chance to get its pants on.”
― Winston S. Churchill

1. Introduction

Getting multi-threaded programming right is something of an art; it can be hard to foresee and avoid the many pitfalls. One such hazard comes from attempting to share a variable across multiple threads.

Continue reading “Java ThreadLocal – Proper Usage”