Luninariel

Instructions

Oct 10th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. #Homework 04
  2.  
  3. This assignment involves calculating entropy of passwords.
  4.  
  5. ##Password Entropy
  6.  
  7. Entropy is a measure of how hard it would be to guess a password. There are several ways of calculating entropy. The different methods tend to give slightly different numbers, but Entropy is really just an estimate. The formula we will use is probably not the best formula, but it is straightforward and serves our purposes.
  8.  
  9. ###E = log2(R(L-1))
  10.  
  11. where
  12. E is an integer representing the maximum entropy. (Truncate the decimal part; don't round)
  13. R is the range of the characters.
  14. range is 26 if only lower case letters are used
  15. range is 52 if upper and lower case letters are used
  16. range is 62 if upper, lower, and digits are used.
  17. range is 67 if upper, lower, digits, and 5 special characters are used.
  18. range is 72 if upper, lower, digits, and 10 special characters are used.
  19. ####Range To calculate range, set range to 0
  20.  
  21. Add 26 if there is 1 or more upper case characters
  22. Add 26 if there is 1 or more lower case characters
  23. Add 10 if there is 1 or more digits (0 through 9)
  24. Add 1 for each special character in the set "`~!@#$%^&*()-_=+[{]}|;:'",<.>/?</.>" If a character occurs more than once, it is only counted 1 time.
  25. ###Log2
  26.  
  27. Java does not have a built-in method for logs in base 2. However, you may calculate a base 2 log by using the following formula.
  28.  
  29. double result = Math.log(number) / Math.log(2));
  30. You will need to do some unit tests on your log2(number) method. Here are some useful values. You may use a calculator to get some additional values to test. You should have at least 20 values tested in the log2() test.
  31.  
  32. Log2(1) is 0.000000
  33. Log2(2) is 1.000000
  34. Log2(3) is 1.584963
  35. Log2(4) is 2.000000
  36. Log2(5) is 2.321928
  37. Log2(16) is ________ (You should be able to figure this out)
  38. Log2(0) is -Infinity
  39. Log2(-1) is NaN (Not a number)
  40. Log2(.5) is -1
  41. Log2(.25)is -2
  42. Log2(0.12345) is-3.01800125841
  43. Log2(45.3) is 5.50143914516
  44. ##Running Tests
  45.  
  46. There are currently a couple of unit tests written for you. However, the tests will fail. When a test fails the error is usually in the code, but it can be in the test. In this case I am telling you up front that the errors are in the tests.
  47.  
  48. First, run the existing tests and correct them.
  49. Complete the missing parts of the main class. You will have to complete and write several methods.
  50. Write test cases for all methods that return a value. Run those tests. Generally you should have approximately 20 tests per method. Be sure you are checking all possible values (negative, zero, positive, fractions, etc). Get all of the tests running correctly.
  51. Zip your file and turn it in.
Advertisement
Add Comment
Please, Sign In to add comment