Thursday, 6 October 2016

MD5 In Java

MD5 In Java

Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string. Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value. It is also used in many encryption algorithms.

ALGORITHM
MD5 processes a variable-length message into a fixed-length output of 128 bits. The input message is broken up into chunks of 512-bit blocks (sixteen 32-bit words); the message is padded so that its length is divisible by 512. The padding works as follows: first a single bit, 1, is appended to the end of the message. This is followed by as many zeros as are required to bring the length of the message up to 64 bits fewer than a multiple of 512. The remaining bits are filled up with 64 bits representing the length of the original message, modulo 264.
The main MD5 algorithm operates on a 128-bit state, divided into four 32-bit words, denoted ABC, and D. These are initialized to certain fixed constants. The main algorithm then uses each 512-bit message block in turn to modify the state. The processing of a message block consists of four similar stages, termedrounds; each round is composed of 16 similar operations based on a non-linear function F, modular addition, and left rotation. Figure 1 illustrates one operation within a round. There are four possible functions F; a different one is used in each round:
 denote the XOR, AND, OR and NOT operations respectively.

IMPLEMENTATION IN JAVA

import java.security.*;
import java.math.*;

public class MD5 {
    public static void main(String args[]) throws Exception{
        String s="This is a wCodes";
        MessageDigest m=MessageDigest.getInstance("MD5");
        m.update(s.getBytes(),0,s.length());
        System.out.println("MD5: "+new BigInteger(1,m.digest()).toString(16));
    }
}

2.Another WORKING Sample of Code:


MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(StandardCharsets.UTF_8.encode(string));
return String.format("%032x", new BigInteger(1, md5.digest()));
3.The Other Way Is By Using The Guava Hashing Method
Hasher hasher = Hashing.md5().newHasher();
hasher.putString("my string");
byte[] md5 = hasher.hash().asBytes();

FUTURE OF MD5

As MD5 and SHA-1 have significant (theoretical) weaknesses, they evidently should be withdrawn from applications. However, practice shows that the industry responds slowly in replacing them with secure hash function standards. To alleviate possible damage by collision attacks, we have introduced a technique that efficiently detects both identical-prefix and chosen-prefix collision attacks against both MD5 and SHA-1 given only one of the two documents in a collision. Such an indication can be used to abort further processing or communications, before sensitive information can be accessed or transmitted.
The future de facto hash function standard SHA-3 is currently being selected in an international competition by the National Institute of Standards and Technology (NIST) in the U.S. Nevertheless, due to the continued usage of SHA-1 in the foreseeable future, more research is needed on the real-world security of SHA-1 and on whether our ideas can be extended to other important hash function standards such as the future SHA-3.

Friday, 23 September 2016

We need some refreshments to energize !!!


wCodes Blog needs to get re-programmed for an upgrade.

This message is to inform you that I will be very busy upgrading this blog to make it more structured and purposeful for the next few days. Keeping in mind the huge traffic, I will not put the entire site down, but you might encounter several unforeseen circumstances while browsing over post in this blog. I am really sorry for any trouble that you might encounter.

Trust me, that your endurance is worthwhile. Get ready for a more progressive and structured experience.


Regards,
Shouvik Mitra.
(for wCodes Network)

Wednesday, 21 September 2016

Learn C Programming with Examples & Reference

Hi Guys, its me Shouvik Mitra this side, and I have a good news to share with you.
I am up with C programming language. So, being an open-minded person, from now on, I will share a basic crash course on C which will help you with the fundamentals, and concept building.

This course will mainly be focused toward those who have a less understanding of any programming language




Features of this course:
·         No programming skills required.
·         Huge number of cheat sheets for future references.
·         We gonna build awesome real-life projects as examples.
·         Get the liberty to go through each and every concept in details.

Why is this course created?
Well we all might feel why another course on the C Programming Language. Experience speaks that we all have seen several number of good books on the market explaining C, but, myself being a computer science student feel the need of such a book where we learn through interactive real-life examples. This course mainly deals with learning from examples and references, which you can find in any book.

Whom is this course meant for?
In colleges, most first semester students who has never done programming before feels horrible while their class-mates with a programming background relishes the time. Well this series of tutorials can prove to be very helpful for people like them. Also, this material can come to some help for the programming geeks who just wanna peak through several amazing examples to refurbish their knowledge.


Saturday, 3 September 2016

Creating a Calculator in JAVA


Step 1: Creating a new project


·         Click on the file menu and then select New Project.

·         Now select the Java node from the Categories on the left and select Java Application from the Projects menu on the right.
Click Next.

n

·         Now name the project as Calculator and leave the Create Main Class check box unselected.




·         Now you will see the project in the projects view on the left. Now Right_Click the project and follow the steps below. 


Now select JFrame Form
·      Now provide the name to the JFrame Form. Ignore the messages displayed at the bottom.
For detailed explanation See Here.

Now click finish.

·         Now you will be shown the design view. Now create the layout below using the pallete on the right.
Drag a jtextfield on the design area.
Now drag and drop a jpanel. Set the layout of the jpanel to be gridlayout.
Now Click on the gridlayout from the navigator view on the left and move to the properties view on the right.
Now drag and drop 16 buttons from the pallete to the jpanel on the design area.

·        

After creating the above format, copy and paste the code given below.
·         Enjoy your first java made calculator.

:: Source code ::



CHEERS!!!



Wednesday, 18 May 2016

Creating a screen shot application in JAVA

Ever wondered about creating your own screenshot application in java? If yes, then this post is for you!
Today, I share with you a code for creating a simple class capable of capturing your screen and saving it in a screen.jpg named file. With much delay lets have a look at the code.

Creating a simple Task Manager in java

Hey Guys, today I will show you how to create a simple task manager in java. For achieving this aim, I am going to make use of a application preloaded on all Windows machines. I am afraid, this trick and also the program shall not work for any non-windows platform. So, without much delay, let me present the code in front of you.