BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-04-2007, 05:17 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: TDC
Posts: 115
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default convert String to long

Please Login to Remove!

I want to convert my pin+some text i have into a long.

I want this to be done at runtime, so the rightclicking wont help me.

Anyway i can do this?
Offline  
Old 10-04-2007, 05:32 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Long.parseLong(String s)

hth,
simon
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 10-04-2007, 07:02 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: TDC
Posts: 115
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

that my friend, will give you an exception...
Offline  
Old 10-04-2007, 07:09 AM   #4 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

it's been a while since i did it but i think i remember that the jde uses the sha1 algorithm to create the long for use in key stores.

simon was thinking you just wanted to convert a long number represented by a string to long.
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 10-04-2007, 07:17 AM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: TDC
Posts: 115
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by jfisher View Post
it's been a while since i did it but i think i remember that the jde uses the sha1 algorithm to create the long for use in key stores.

simon was thinking you just wanted to convert a long number represented by a string to long.
well... i wrote pin+some text

you wouldnt by any chance have a fancy method that did the work would u?
Offline  
Old 10-04-2007, 07:29 AM   #6 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

it was for a module that added the rim jde string to long functionality to netbeans, i used the bouncycastle digest:

SHA1Digest sha1Digest = new SHA1Digest();
sha1Digest.update(String2Convert.getBytes(), 0, String2Convert.length());
byte[] hashValBytes = new byte[sha1Digest.getDigestSize()];
sha1Digest.doFinal(hashValBytes, 0);
long hashValLong = 0;

for( int i = 0; i < 8; i++ ) {
hashValLong |= ((long)(hashValBytes[i]) & 0x0FF)<<(8*i);
}
String hexString = "0x" + Long.toHexString(hashValLong) + "L";
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.