
Symbian Series 40 java HMACSha256 routine
5159
$$
- Posted:
- Proposals: 2
- Remote
- #139734
- Archived
Description
Experience Level: Intermediate
As I can't find a native HMACSha256 routine in the Java libraries for Symbian Series 40.
We require a Java HMACSha256 routine written to work on a Nokia Series 40 mobile devices.
Internally we are porting an Android application to work on Symbian phones. Our dev environment is Elcipse and JavaME library [Nokia
SDK1.1 for Java/Nokia_SDK_1_1_Java] and a Java Compliance level of 1.3.
When running the HMACSha256 routine, it will need to accept 2 inputs :
Message - String of length 16 eg. 1234567890123456 (receive only numbers for our routine)
salt - byte[] of length 32 eg.
[18, 52, 86, 120, -112, 18, 52, 86, 120, -112, 18, 52, 86, 120, -112, 18, 52, 102, 72, -96, 34, 4, 102, 72, -96, 34, 4, 102, 72, -96,
34, 4]
With the above inputs the following result should be
140222341996612811960157391723124820121629210035133133167832812823411673163509311
Below is the Android Java code that requires porting.
private static String HMACSha256Hash(String Message, byte[] seed) {
String retValue = "";
double doubleValue;
long ii = 0;
byte[] bMesg = null;
byte[] tmpReversedMesg;
// First we convert the message into a Long so that it is 8 Bytes / 64 Bit
try{
ii = Long.parseLong(message);
}catch (NumberFormatException nfe){
ii=0;
}
// The 64 Bit is then placed into a Byte array
bMesg = longToByteArrayReversed(ii);
String s;
try {
Key sk = new SecretKeySpec(seed,"HmacSHA256" );
Mac sha256_HMAC = Mac.getInstance(sk.getAlgorithm());
sha256_HMAC.init(sk);
final byte[] hmac = sha256_HMAC.doFinal(bMesg);
// At this stage we have a signed Byte array which we need to manipulate
//convert the byte to hex format method 1 and then convert the hex to in for the string build up.
for (int i = 0; i < hmac.length; i++) {
s = Integer.toString((hmac[i] & 0xff) + 0x100, 16).substring(1);
retValue += Integer.valueOf(s, 16).intValue();
}
}catch(Exception e){
return null;
}
return retValue;
}
We require a Java HMACSha256 routine written to work on a Nokia Series 40 mobile devices.
Internally we are porting an Android application to work on Symbian phones. Our dev environment is Elcipse and JavaME library [Nokia
SDK1.1 for Java/Nokia_SDK_1_1_Java] and a Java Compliance level of 1.3.
When running the HMACSha256 routine, it will need to accept 2 inputs :
Message - String of length 16 eg. 1234567890123456 (receive only numbers for our routine)
salt - byte[] of length 32 eg.
[18, 52, 86, 120, -112, 18, 52, 86, 120, -112, 18, 52, 86, 120, -112, 18, 52, 102, 72, -96, 34, 4, 102, 72, -96, 34, 4, 102, 72, -96,
34, 4]
With the above inputs the following result should be
140222341996612811960157391723124820121629210035133133167832812823411673163509311
Below is the Android Java code that requires porting.
private static String HMACSha256Hash(String Message, byte[] seed) {
String retValue = "";
double doubleValue;
long ii = 0;
byte[] bMesg = null;
byte[] tmpReversedMesg;
// First we convert the message into a Long so that it is 8 Bytes / 64 Bit
try{
ii = Long.parseLong(message);
}catch (NumberFormatException nfe){
ii=0;
}
// The 64 Bit is then placed into a Byte array
bMesg = longToByteArrayReversed(ii);
String s;
try {
Key sk = new SecretKeySpec(seed,"HmacSHA256" );
Mac sha256_HMAC = Mac.getInstance(sk.getAlgorithm());
sha256_HMAC.init(sk);
final byte[] hmac = sha256_HMAC.doFinal(bMesg);
// At this stage we have a signed Byte array which we need to manipulate
//convert the byte to hex format method 1 and then convert the hex to in for the string build up.
for (int i = 0; i < hmac.length; i++) {
s = Integer.toString((hmac[i] & 0xff) + 0x100, 16).substring(1);
retValue += Integer.valueOf(s, 16).intValue();
}
}catch(Exception e){
return null;
}
return retValue;
}
Phillip N.
100% (6)Projects Completed
5
Freelancers worked with
2
Projects awarded
73%
Last project
16 Nov 2018
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies