BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/index.php)
-   Developer Forum (http://www.blackberryforums.com/forumdisplay.php?f=15)
-   -   Encryption using SHA1 of User ID and Password (http://www.blackberryforums.com/showthread.php?t=254008)

admireravi 10-02-2011 03:51 AM

Encryption using SHA1 of User ID and Password
 
I am creating a blackberry application which sends the request to the server. So authentication of the user is required here. So for doing this i want to hash UserID and password using SHA1 in blackberry. The hashed data is encoded and then passed to the server for authentication.
My problem is how do i implement this. Can someone give the sample code for implementing this in blackberry.
Thanks

dc/dc 10-02-2011 06:21 AM

Re: Encryption using SHA1 of User ID and Password
 
You need to post in the Developer section.

hrbuckley 10-02-2011 08:09 AM

Re: Encryption using SHA1 of User ID and Password
 
Code:

String userid, password;
...
SHA1Digest sha1 = new SHA1Digest();

sha1.update(userid.getBytes(), 0, userid.length());
byte[] userHash = new byte[sha1.getBlockLength()];
sha1.getDigest(userHash, 0, true);

sha1.update(password.getBytes(), 0, password.length());
byte[] passHash = new byte[sha1.getBlockLength()];
sha1.getDigest(passHash, 0, true);


Dubdub 10-02-2011 11:25 AM

Re: Encryption using SHA1 of User ID and Password
 
Moved to the Developer Forum.


All times are GMT -5. The time now is 10:52 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.