Posts

Encrypt and Decrypt Images Using Java

Hi, Most of you would find it useful to Encrypt a special picture of yours such that only you can view it. By using JCE(Java Cryptography Extension) classes, this becomes very simple. As I have already done before using Java to encrypt a String is very simple. If you are new to this, please read the article which I had already posted named "Java Encryption and Decryption" at "http://ruchiram4.blogspot.com/2009/04/java-encryption-and-decryption.html" Also, you need to have a basic understanding of Java IO. If you are new, it is better to read the Sun Java tutorial on IO. Before we move on, lets recall the basic steps in Encrypting plaintext. 1. Creating an instance of "Cipher" object and setting the mode of Encryption (Eg: AES, DES) 2. Generating a key by using a KeyGenerator object. 3. Setting the mode of Cipher operation on the Cipher object. As we intent to Encrypt, we simply set it by setting a property of Cipher object by calling its "init"...

Off The Record Protocol (OTR)

Off The Record Protocol (OTR) is one of the emerging protocols today. It is becoming more and more popular amongst Internet Messenger Services by providing a service similar to a conversation by two people. Internet Messenger Applications such as Pidgin has already implemented such a plugin fo the application and other messenger services are already on the move with implementing the feature. OTR provides the two parties to have a conversation between them by providing the following features. i) Encryption : Messages can be read by only the two parties involved. ii) Authentication : Lets each parties know that they are chatting with the person who they think they are. In simpler terms, this features prevents forging by a third party by imitating the other person. iii) Deniability(Repudiability) : This is a controversial term. We are very much used with the term 'Non Repudiability' when we talk about Computer Security. But here, we specifically allow repudiability to occur. iv) P...

Java Encryption and Decryption

Hi Folks, Most of you would be very much interested to know how to use java to do crypto work. In this post, I would demonstrate how to use JCE(Java Cryptography Extension) Classes and methods to very simply Encrypt and Decrypt a PlainText. This article is intended for an audience who is familiar with cryptography concepts and is looking for an implementation of such an algorithm in Java. If you are looking to learn Cryptography concepts, this post may not be helpful. JCE provides us with a bunch of useful classes to accomplish this. I would demonstrate how to do so using Cipher class. Cipher class is handy to handle such task. You can get an instance of a Cipher Class by calling its static method ENCRYPTION Cipher cipher=Cipher.getDefaultInstance("DES"); This accepts a string indicating the encrypting algorithm. For now, we will use DES(Data Encryption Standard) In order to Encrypt, we need a key. A key can be easily generated by using the KeyGenerator Class provided. KeyGen...

Build your own SNMP Monitoring Tool

Image
SNMP is a protocol used widely for monitoring and extracting status information of a working device. Using SNMP protocol, you can extract the present information about a certain device. It is widely used for monitoring network devices such as Routers. But, practically any device which supports SNMP protocol can be used. As an example consider a SNMP enabled network printer inside an organization. The Network admin can issue necessary commands to the SNMP enabled device to get the status of the printer to check the status of the printer to see whether it is working as it should. Furthermore, the SNMP enabled device can be configured to issue an alert once a condition is met. As an example, there may be a Network printer which can be configured to make an alert once the ink level drops below a certain level. The breadth of SNMP is determined by the capabilities embedded into the device itself. Another very useful scenario is where a JVM(Java Virtual Machine) can be SNMP enabled to be mon...

How to pass a collection of data to SQL Server

Hi all. If you are faced with a situation where you wish to send an array of strings(say) to the Server, then you have stumbled to the correct page :-) To start off with, SQL server up to 2005 does not support Arrays. So, it becomes a bit difficult for Java,C#,C++ programmers who are very fond of arrays to get their job done. Fortunately there is a detour which enables us to get the job done. Instead of sending the list as an array, we can append a delimiter(here I used the comma) and send the complete string to the server side. At the server side, it splits the separate strings by the delimiter and inserts them into a table(her I used it as a single column table of the form tmpTable(_name varchar(50))) You can use the values inserted into this table and use the results similar to having an array. NOTE: It does not support the sophisticated array functions you are used to, but it will let you get the job done. /* PROCEDURE NAME : readCSV AUTHOR : Ruchira Randana PROCEDURE DESC...

Connect SQL Server Express 2005 with NetBeans IDE

Image
Hi, Most of you Java Folks may have encountered situations where you wish to code using Java but need to connect to a Microsoft SQL Server Database. To an experienced person, this may seem trivial, but for newbies, this can be a troublesome task. Through this post, I would briefly describe how to connect to Microsoft SQL Server 2005 Express Edition using NetBeans 6.0.1 IDE. STEP 1: Download the relevant JDBC driver from the microsoft site. (A search on the internet will more than suffice) STEP 2: Add the driver to NetBeans IDE. This can be done as follows. On the services tab, under Databases under Drivers, you can add a new driver as follows On the Window, click Add and select the necessary Jar file of the driver. Then click Find. It will search the class name and display it as follows Once the driver is installed, you can right click on it and click 'connect using' Then you will get the following screen Fill in your database name and host address. The port is usually 1433. Yo...

Sending Mail Using Java

Image
In this post, I would like to discuss how to send an e-mail using javax.mail library. I will discuss how to send an e-mail for the simplest case. ie: I present my example for a scenario without authorization and other related issues. Once you get this mail application up and running, you can extend it further. I would regard my example as a beginner's starting position. As I preffer to say, "Start from trivial" Dont't start your application with all complications and Network issues. You will get frustrated very soon. Once you get the trivial running, add the other requirements as features to your application. In order to get started, you need an SMTP server. (When I mean a server, it does not necessarily mean a seperate machine running as a server. You can simply run a server application on your own machine) An SMTP(Simple Mail Transfer Protocol) server is very similar to a post box. You pop a mail with the destination address stamped and, it takes care of delivering ...