I'm looking at implementing an app getting Twitter authorization via Oauth in Java. The first step is getting a request token. Here is a Python example for app engine. To test my code, I am running Python and checking output with Java. Here is an example of Python generating a Hash-Based Message Authentication Code (HMAC):
#!/usr/bin/python
from hashlib import sha1
from hmac import new as hmac
key = "qnscAdgRlkIhAUPY44oiexBKtQbGY0orf7OV1I50"
message = "foo"
print "%s" % hmac(key, message, sha1).digest().encode('base64')[:-1]
Output:
$ ./foo.py
+3h2gpjf4xcynjCGU5lbdMBwGOc=
How does one replicate this example in Java?
Here is an HMAC Java example. It uses javax.crypto.Mac, all good. However, the SecretKey constructors take bytes and an algorithm. What's the algorithm in the Python example? How can one create a Java secret key without an algorithm?