Gemalto is now part of the Thales Group, find out more.

You are here

JSR177 Encryption And Decryption Very Simple Example

Showcase, November 18, 2016 - 5:30pm, 965 views

This is a short MIDlet that demonstrates the usage of JSR177 API.

A short text is encrypted and decrypted with the AES algorithm and AES/CBC/PKCS5Padding transformation.

 

Updated: 24/08/2018

The example was updated. Some more algorithms and transformations were added:

AES/CBC/PKCS5Padding

AES/ECB/PKCS5Padding

AES/ECB/NoPadding

AES/CBC/NoPadding

DES/ECB/PKCS5Padding

DES/ECB/NoPadding

DES/CBC/PKCS5Padding

DES/CBC/NoPadding

ARC4//NoPadding

antero.markkula@enkom.fi's picture
antero.markkula...

Hi !

This kind of examples are exactly what is required.
I tried this on a EHS6T USB terminal and a ELS61-E module and both are working fine.  This is the stdout:

SYSTEM.OUT STARTED
JSR177Example: Creating main class
JSR177Example: Starting the application
Message: This is a test message to be encoded and decoded.
Message as bytes:[84,104,105,115,32,105,115,32,97,32,116,101,115,116,32,109,101,115,115,97,103,101,32,116,111,32,98,101,32,101,110,99,111,100,101,100,32,97,110,100,32,100,101,99,111,100,101,100,46]
Encrypted message: ÅE†˜eÎùÿ“€höT·_»tV¸FNÒ’0žG,Ôòœ¨<Hxm<Â%]ª0^ò"6M̺Þ
                                                                     Q'þ74¼™I{
Encrypted message as bytes:[-59,69,-122,-104,101,-50,20,-7,-1,-109,-128,104,-10,84,-73,95,20,5,-69,116,86,-72,70,78,-46,-110,48,-98,71,44,-44,-14,-100,-88,60,72,120,109,60,-99,-62,37,93,-86,48,94,-14,34,54,17,77,-52,-70,-34,11,81,39,-2,55,52,-68,-103,73,123]
Decrypted message: This is a test message to be encoded and decoded.
Decrypted message as bytes:[84,104,105,115,32,105,115,32,97,32,116,101,115,116,32,109,101,115,115,97,103,101,32,116,111,32,98,101,32,101,110,99,111,100,101,100,32,97,110,100,32,100,101,99,111,100,101,100,46]
JSR177Example: Stopping the application
MIDlet:com.gemalto.m2m.jsr177.Main exited

Antero Markkula
Communication and Mechatronics

Enkom Active Oy – www.enkom-active.fi
Upseerinkatu 3 A, 02600 Espoo, Finland
Mobile: +358 400 411368
Office: +358 10 204 0000
Fax: +358 10 204 0010
E-mail: antero.markkula@enkom-active.fi

Bartłomiej Gemalto Moderator