Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Urgent help needed in Java ! Thanx Code given : myhash.java import java.security.MessageDigest; public class MyHash { private static MessageDigest md; public static byte[] hash(byte
Urgent help needed in Java ! Thanx
Code given :
myhash.java
import java.security.MessageDigest;
public class MyHash {
private static MessageDigest md;
public static byte[] hash(byte [] m) {
byte[] ret = new byte[3];
byte[] h;
try {
md = MessageDigest.getInstance("SHA-256");
}
catch (java.security.NoSuchAlgorithmException e)
{}
h = md.digest(m);
ret[0] = h[0];
ret[1] = h[1];
ret[2] = h[2];
return ret;
}
}
Part 1 Write a program that finds collisions in "myhash", available on Blackboard. (myhash outputs a hash of 24 bits). List how many hash values, on average, you have to hash before you find a collision. Then, estimate how many values you would need to hash to find a collision in SHA256 Part 2 Find the pre-image for the following hash values, computed using SHA-256. The values being hashed are New York City number plates. The format of the number plates is LLLNNNN, where L is a capital letter and N is a number, represented as ASCII characters (e.g., "ABC1234"): 0x5BE5D918B4C69B4D3D92DEE5FF9322AF0448DB2E71B5699C36FF984F6DD6A211 0xC58A3CADO2B605D2197196D8E8887619DFEDACEAB4D5052234C5BCE76ED39D18 0x6CDEF54A898CBAOA6F7036F9E4FC98760AFOCF93ED3C5C157294DACE6BABAD5D 0x565FA556A01A9AEC9724E74379417F7650C89C89F72CB3608F6172063225AA54 0xF3B35CB1533BCAC88B46D8CEB9362B2CB6049F745F860C3F673AD9472383A803 0x35A7B77F49169356E5640FBEOBEOFF8F093524B99CB3FF206BCE888F08B5OA41 0x12B904372337CD7739BE3712D7D648F1E4A936F AD76OAAF2C267C3335736ECD8 For reference SHA256 (ABC 1234) sha256 (BGR7364) sha256 (XYZ432 1) 0x379AE4C32C826F265C49COB 17432FFB18C1BCCABC79CEDE66A99984403FC4AE4 -0x5949996C348A8F92B659E63816D6CF11C8B973B7D4721B65BBC536C209A5AF8A = 0x0AD6B97A4F2E1272268AA5A39164876BE922ABC4 13AE5E02408F1CA683715017 Submit two files containing the source code of the programs in Part 1 and Part 2, and a PDF document explaining reporting the number plates from Part 2 and your estimates from Part 1. If your program is written in Java, it will be executed from the command line, and tested as iavacFindCollisions.iava iava FindCollisions Part 1 Write a program that finds collisions in "myhash", available on Blackboard. (myhash outputs a hash of 24 bits). List how many hash values, on average, you have to hash before you find a collision. Then, estimate how many values you would need to hash to find a collision in SHA256 Part 2 Find the pre-image for the following hash values, computed using SHA-256. The values being hashed are New York City number plates. The format of the number plates is LLLNNNN, where L is a capital letter and N is a number, represented as ASCII characters (e.g., "ABC1234"): 0x5BE5D918B4C69B4D3D92DEE5FF9322AF0448DB2E71B5699C36FF984F6DD6A211 0xC58A3CADO2B605D2197196D8E8887619DFEDACEAB4D5052234C5BCE76ED39D18 0x6CDEF54A898CBAOA6F7036F9E4FC98760AFOCF93ED3C5C157294DACE6BABAD5D 0x565FA556A01A9AEC9724E74379417F7650C89C89F72CB3608F6172063225AA54 0xF3B35CB1533BCAC88B46D8CEB9362B2CB6049F745F860C3F673AD9472383A803 0x35A7B77F49169356E5640FBEOBEOFF8F093524B99CB3FF206BCE888F08B5OA41 0x12B904372337CD7739BE3712D7D648F1E4A936F AD76OAAF2C267C3335736ECD8 For reference SHA256 (ABC 1234) sha256 (BGR7364) sha256 (XYZ432 1) 0x379AE4C32C826F265C49COB 17432FFB18C1BCCABC79CEDE66A99984403FC4AE4 -0x5949996C348A8F92B659E63816D6CF11C8B973B7D4721B65BBC536C209A5AF8A = 0x0AD6B97A4F2E1272268AA5A39164876BE922ABC4 13AE5E02408F1CA683715017 Submit two files containing the source code of the programs in Part 1 and Part 2, and a PDF document explaining reporting the number plates from Part 2 and your estimates from Part 1. If your program is written in Java, it will be executed from the command line, and tested as iavacFindCollisions.iava iava FindCollisionsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started