Posts

Showing posts with the label Core Java

Hashing in Java - MD5 ,SHA-1, SHA-256, SHA-384,SHA-512 and PBKDF2

Image
What does Hashing mean? A secure password hash is an encrypted sequence of characters obtained after applying certain algorithms and manipulations on user-provided password, which are generally very weak and easy to guess. Please remember that once this password hash is generated and stored in the database, you can not convert it back to the original password. MD5 hash in Java The MD5 message-digest algorithm is a widely used hash function producing a 128-bit hash value. Although MD5 was initially designed to be used as a cryptographic hash function, it has been found to suffer from extensive vulnerabilities. It can still be used as a checksum to verify data integrity, but only against unintentional corruption. It remains suitable for other non-cryptographic purposes, for example for determining the partition for a particular key in a partitioned database. Example: Java-MD5 to hash a String import java.nio.charset.StandardCharsets; import java.security.MessageDigest; i

Java - DES Encryption and Decryption example

DES (Data Encryption Standard) algorithm is the most commonly used encryption  symmetric-key  algorithm in the world. For a long time, "cipher generation" was synonymous with DES in many people's minds. Although the Electronic Frontier Foundation recently called, it built a 220,000 machine to try to crack DES encrypted data. DES and its variant "triple data encryption algorithm" will still be widely used in government and banking. AES became the replacement for DES).   DES processes bits or binary numbers. We know that every four bits make up a hexadecimal number. DES encrypts a set of 64-bit information, which is represented by 16 hexadecimal numbers. DES also uses 64-bit long ciphers to provide encryption. However, every 8 bits in the key are ignored, resulting in a correct key length of 56 bits in DES. However, in any case, one 64-bit block is an eternal DES organization. Java DES Encryption and Decryption   import javax.crypto.Cipher; import javax.crypto.K