develop a algorithm to implement MD5 in Java to encrypt/hash passwords with salt.
CODE
public class SaltedMD5Example
{
public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchProviderException
{
String passwordToHash = "password";
byte[] salt = getSalt();
String securePassword = getSecurePassword(passwordToHash, salt);
System.out.println(securePassword); //Prints 83ee5baeea20b6c21635e4ea67847f66
String regeneratedPassowrdToVerify = getSecurePassword(passwordToHash, salt);
System.out.println(regeneratedPassowrdToVerify); //Prints 83ee5baeea20b6c21635e4ea67847f66
}
private static String getSecurePassword(String passwordToHash, byte[] salt)
{
String generatedPassword = null;
try {
// Create MessageDigest instance for MD5
MessageDigest md = MessageDigest.getInstance("MD5");
//Add password bytes to digest
md.update(salt);
//Get the hash's bytes
byte[] bytes = md.digest(passwordToHash.getBytes());
//This bytes[] has bytes in decimal format;
//Convert it to hexadecimal format
StringBuilder sb = new StringBuilder();
for(int i=0; i< bytes.length ;i++)
{
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
}
//Get complete hashed password in hex format
generatedPassword = sb.toString();
}
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return generatedPassword;
}
//Add salt
private static byte[] getSalt() throws NoSuchAlgorithmException, NoSuchProviderException
{
//Always use a SecureRandom generator
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "SUN");
//Create array for salt
byte[] salt = new byte[16];
//Get a random salt
sr.nextBytes(salt);
//return salt
return salt;
}
}
develop a algorithm to implement MD5 in Java to encrypt/hash passwords with salt.
C code: hash program (use the Fowler-Noll-Vo (FNV) hash algorithm) This is a simple program that you will use in the second part of the assignment. Details of this program is as follows. A hashing algorithm is simply an algorithm that maps data of an arbitrary size into a hash value of a fixed size. On your VM, you should have a program called ”md5sum”, which computes the MD5 hash of a file (or bytes taken from standard input). One...
3 Brute Force Attack vs Birthday Attack (50 pts) Message-Digest Algorithm (MD5) and Secure Hash Algorithm 1 (SHA-1) are com- monly used cryptographic hash functions 1. Do research to find the numbers of bits used in MD5 and SHA-1. (8 pts) perform An adversary an attack to a hash algorithm by applying random inputs can and y (y) that satisfie Hx) and repeating until finding two inputs H(y) where H() denotes a hash code. This is called a "hash collision."...
3 Brute Force Attack vs. Birthday Attack (50 pts) Message-Digest Algorithm (MD5) and Secure Hash Algorithm 1 (SHA-1) are com- monly used cryptographic hash functions 1. Do research to find the mmbers of bits used in MDS and SHA-1. (8 pts) 3 Brute Force Attack vs. Birthday Attack (50 pts) Message-Digest Algorithm (MD5) and Secure Hash Algorithm 1 (SHA-1) are com- monly used cryptographic hash functions 1. Do research to find the mmbers of bits used in MDS and SHA-1....
Design & Analysis of Algorithms Implement the algorithm in Java of the following problem
Java Language Implement hash tables using open addressing and chaining Test your implementation with sample values.
Write a short Java program that uses private key (symmetric) encryption method to encrypt a short string. Approximate algorithm: Enter a text string Use Java to generate a key and encrypt the string Use Java (and the key) to decrypt the string Compare original and decrypted string to make sure it is the same Note: Please make it as simple as possible
Implement the binary reflected Gray code algorithm for generating subsets in Java
Objective: Implement a sorting algorithm. Description: Implement a radix sort in a Java class named RadixSort.java. Your program should receive its input from a file named "input.txt", which contains one integer per line. It should produce a sorted output file named "output.txt". Include a main method which demonstrates that your algorithm works.
Implement a recursive algorithm (implemented in Java) that checks if a number is identical when read both forwards and backwards