BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 10-02-2011, 04:51 AM   #1 (permalink)
New Member
Join Date: Sep 2011
Model: none
Carrier: AIRTEL
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question Encryption using SHA1 of User ID and Password

Please Login to Remove!

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.

Last edited by admireravi : 10-02-2011 at 05:04 AM.
Old 10-02-2011, 07:21 AM   #2 (permalink)
Spam Reporter
dc/dc's Avatar
Join Date: Oct 2005
Location: IAD
Model: 6230
Carrier: Voicestream
Posts: 14,530
Post Thanks: 220
Thanked 345 Times in 311 Posts
Default Re: Encryption using SHA1 of User ID and Password

You need to post in the Developer section.
I h8 txtspk.
Old 10-02-2011, 09:09 AM   #3 (permalink)
BlackBerry Extraordinaire
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: Encryption using SHA1 of User ID and Password

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);
My other Blackberry is a PlayBook.
Old 10-02-2011, 12:25 PM   #4 (permalink)
Dubdub's Avatar
Join Date: Nov 2005
Location: New Hampshire
Model: App6+
PIN: Ask
Carrier: ATT & Verizon
Posts: 20,038
Post Thanks: 54
Thanked 783 Times in 743 Posts
Default Re: Encryption using SHA1 of User ID and Password

Moved to the Developer Forum.
-->>BB FAQ

-->>Stinsonddog's Tip Site!


If someone helps, tell them by clicking the Thanks button.!!
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Copyright 2004-2014
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.