Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
mobiledevfan
Posts: 11
Registered: ‎12-31-2009
Accepted Solution

Questions about Random and SHADigest

Hi there,

 

 I used the following code to to verify activation codes for my application. Some users complained that the activation code were invalid. However I verified the activation codes on my own device and it worked. Do some BlackBerry get different result for SHA1Digest  or Random function with the same parameters?

 

 

  SHA1Digest sha1Digest = new SHA1Digest();
  sha1Digest.update(("" + pin).getBytes());
  ....
  Random rand = new Random(pin);
 ....

 

 

 Thanks

 

MobiDevFan

Please use plain text.
Developer
vivart
Posts: 147
Registered: ‎08-27-2010
My Carrier: airtel

Re: Questions about Random and SHADigest

[ Edited ]

SHA1Digest algorithm is same for all platform. 

 

but getBytes() method can return different values depending on encoding used in device or server.

 

so use consistent encoding every every.

 

e.g.

 

 

getBytes("UTF-8")

 

 

 

Please use plain text.
New Developer
mobiledevfan
Posts: 11
Registered: ‎12-31-2009

Re: Questions about Random and SHADigest

Great! Thanks for your helpful answer. I hope there is no complaint any more. :smileytongue:

Please use plain text.