Announce two new product: SmartCard Reader Rockey200 and USB2.0 Extension Cable

ROCKEY 200 is a handy and portable USB Smart Card reader that can perform read/write operations on any ISO 7816-1/2/3/4 smart cards which are compatible with protocol T=0 and T=1.

USB2.0 Extension Cable With high speed USB 2.0 devices such as USB token ,USB Card Reader and so on.

Come to try it now!

How to generate random data?

Algorithm School

Moderator: UNKNwYSHSA

Posts: 2
Joined: Sun Mar 18, 2018 10:47 pm
Points: 28

How to generate random data?

Postby javaABC » Tue Mar 20, 2018 5:27 am

as the title, how to generate random data in my applet?

Posts: 9
Joined: Thu Sep 10, 2015 4:43 am
Points: 504

Re: How to generate random data?

Postby javacardx » Tue Mar 20, 2018 5:54 am

You can reference this first,maybe it is useful.

Posts: 23
Joined: Tue Aug 25, 2015 8:21 am
Points: 140

Re: How to generate random data?

Postby bigWhite » Wed Mar 21, 2018 3:00 am

Code: Select all

RandomData rand = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
short lenBytes = (short) (KeyBuilder.LENGTH_DES3_3KEY/8);
byte[] buffer = JCSystem.makeTransientByteArray(lenBytes, JCSystem.CLEAR_ON_DESELECT);
DESKey key = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_3KEY, false);

rand.generateData(buffer, (short) 0, lenBytes);
key.setKey(buffer, (short) 0);

The above is a method to generate a random DES key, you can refer

Return to “Algorithm School”

Who is online

Users browsing this forum: No registered users and 1 guest

JavaCard OS : Disclaimer