Advertisement
Guest User

ResponseGenerator.java

a guest
Oct 26th, 2011
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.security.MessageDigest;
  2. import java.security.NoSuchAlgorithmException;
  3.  
  4. import org.apache.commons.codec.binary.Base64;
  5.  
  6. public class ResponseGenerator {
  7.  
  8. public static String toResponseKey(String clientKey) {
  9. try {
  10. String guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
  11. MessageDigest md = MessageDigest.getInstance("SHA-1");
  12.  
  13. byte[] encrypted = md.digest((clientKey + guid).getBytes());
  14. byte[] encoded = new Base64().encode(encrypted);
  15.  
  16. return new String(encoded);
  17. } catch (Exception e) {
  18. e.printStackTrace();
  19. }
  20. return null;
  21. }
  22.  
  23. public static void main(String[] args) throws NoSuchAlgorithmException {
  24. String clientKey = "dGhlIHNhbXBsZSBub25jZQ==";
  25. // String guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
  26. // MessageDigest md = MessageDigest.getInstance("SHA-1");
  27. //
  28. // byte[] encrypted = md.digest((clientKey + guid).getBytes());
  29. // byte[] encoded = new Base64().encode(encrypted);
  30. //
  31. // System.out.println(new String(encoded));
  32.  
  33. System.out.println(toResponseKey(clientKey));;
  34. }
  35.  
  36. }
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement