1

My professor gave us a decryption assignment in which we were given a list of "encrypted" phrases and told to decrypt them. One of them is in blowfish. Me and one of my classmates have tried all the possible keys that he might use. Thus I was going to make a program in Java that would go through all possible keys decrypt the string and then write the decrypted message out to a file. Only problem is all the online tutorials that i can find on writing blowfish in Java have this interface SecretKey being read in from a file.

My question is how do you generate a SecretKey in a program?

Sam
  • 86,580
  • 20
  • 181
  • 179
user678461
  • 13
  • 1
  • 3
  • 3
    Are you sure you've tried *all* the keys? – Greg Hewgill Mar 26 '11 at 22:51
  • see http://stackoverflow.com/questions/5244950/encryption-with-blowfish-in-java, just generate random byte[] data as input (as a cs student you should be able to figure that out). – Johannes Rudolph Mar 26 '11 at 22:52
  • Not every key possible no, but every key that we think he would use. Based off things he's said in class and lists of the most common passwords. – user678461 Mar 26 '11 at 22:53

3 Answers3

2

This might help you:

byte[] key = getKey();
Cipher cipher = Cipher.getInstance("Blowfish");
SecretKeySpec keySpec = new SecretKeySpec(key, "Blowfish");
cipher.init(Cipher.DECRYPT_MODE, keySpec);
WhiteFang34
  • 70,765
  • 18
  • 106
  • 111
0

Use a SecretKeySpec to generate a SecretKey using SecretKeyFactory.generate().

Bombe
  • 81,643
  • 20
  • 123
  • 127