2

I'm trying to encrypt a url-request, username and password, then post it to a webpage.

But for some reason eclipse is saying the syntax is wrong, what am I doing wrong? It is the bit at the bottom where it says md.update that is causing errors.

Here's my code so far:

private static final String apiKey = "38m8nyev284nddci49940303094"; 
private static final String apiUser = "esdt34ds"; 

long unixTimeStamp = System.currentTimeMillis() / 1000L;

String newFeedRequest = "1.0/evoStructure?timestamp=" + unixTimeStamp;
String fixturesFeedURL = "https://secure.website.com/_services/api/" + newFeedRequest;

MessageDigest md = MessageDigest.getInstance("SHA-256");


md.update(fixturesFeedURL.getBytes("UTF-8"),apiKey.getBytes("UTF-8"),apiUser.getBytes("UTF-8")); // Change this to "UTF-16" if needed
byte[] digest = md.digest();

Here is the error I am getting:

Multiple markers at this line

  • Syntax error, insert "Type VariableDeclaratorId" to complete FormalParameterList
  • Syntax error on token "update", Identifier expected after this token
  • Syntax error on tokens, AnnotationName expected instead
  • Syntax error on token ",", @ expected
  • Syntax error on token ",", @ expected
1
  • Would probably help if you say what the error is you're receiving. Commented Apr 16, 2012 at 22:01

1 Answer 1

1

That's a cryptic error. But I'd say your not using correct parameters for update()

http://developer.android.com/reference/java/security/MessageDigest.html

The API shows update(ByteBuffer), update(byte[], int, int), update(byte[]), update(byte). Don't see any that take (byte[], byte[], byte[]) try calling

md.update(fixturesFeedURL.getBytes("UTF-8"));

md.update(apiKey.getBytes("UTF-8"));

md.update(apiUser.getBytes("UTF-8"));

instead

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.