Translate

Показ дописів із міткою Tutorial. Показати всі дописи
Показ дописів із міткою Tutorial. Показати всі дописи

вівторок, 15 липня 2014 р.

How to calculate MD5 and SHA hash values in Java


In cryptography, MD5 (Message Digest version 5) and SHA (Secure Hash Algorithm) are two well-known message digest algorithms. They are also referred as cryptographic hash functions, which take arbitrary-sized data as input (message) and produce a fixed-length hash value. One of the most important properties of hash functions is, it’s infeasible to generate a message that has a given hash (secure one-way). Hash functions are frequently used to check data integrity such as checking integrity of a downloaded file against its publicly-known hash value. Another common usage is to encrypt user’s password in database.
The Java platform provides two implementation of hashing functions: MD5 (produces 128-bit hash value), SHA-1 (160-bit) and SHA-2 (256-bit). This tutorial demonstrates how to generate MD5 and SHA hash values from String or file using Java.


четвер, 16 січня 2014 р.

Configuring JNDI DataSource for Database Connection Pooling in Tomcat


This tutorial shows you how to create a JNDI resource that represents a JDBC DataSource in Tomcat, and then how to configure a Java web application in order to access the JNDI DataSource. The benefits of using a JNDI DataSource are:
  • Utilizing database connection pooling services provided by the container, i.e. Tomcat uses Commons DBCP and Commons Pool as the implementation (tomcat-dbcp.jar).
  • Externalizing database connection and make it independent from the web application itself.
  • Sharing database connections across applications deployed in the container.
The following examples are tested in Tomcat 7 and MySQL Database 5.5.