use of java.security.SecureRandom in project robovm by robovm.
the class myKeyGenerator method testInitKey.
/*
* Test for <code>init(int keysize)</code> and
* <code>init(int keysize, SecureRandom random)</code> methods
* Assertion: throws InvalidParameterException if keysize is wrong
*
*/
public void testInitKey() throws Exception {
byte flag = 0xF;
if (!DEFSupported) {
fail(NotSupportMsg);
return;
}
if (defaultAlgorithm.equals(validAlgorithmsKeyGenerator[validAlgorithmsKeyGenerator.length - 1])) {
return;
}
int[] size = { Integer.MIN_VALUE, -1, 0, 112, 168, Integer.MAX_VALUE };
KeyGenerator[] kgs = createKGs();
SecureRandom random = new SecureRandom();
for (int i = 0; i < kgs.length; i++) {
for (int j = 0; j < size.length; j++) {
try {
kgs[i].init(size[j]);
flag &= 0xE;
} catch (InvalidParameterException ignore) {
flag &= 0xD;
}
try {
kgs[i].init(size[j], random);
flag &= 0xB;
} catch (InvalidParameterException ignore) {
flag &= 0x7;
}
}
}
assertTrue(flag == 0);
}
use of java.security.SecureRandom in project robovm by robovm.
the class CipherInputStream1Test method test_ConstructorLjava_io_InputStreamLjavax_crypto_Cipher.
public void test_ConstructorLjava_io_InputStreamLjavax_crypto_Cipher() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException {
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[100]);
KeyGenerator kg = KeyGenerator.getInstance("DES");
kg.init(56, new SecureRandom());
Key key = kg.generateKey();
Cipher c = Cipher.getInstance("DES/CBC/NoPadding");
c.init(Cipher.ENCRYPT_MODE, key);
CipherInputStream cis = new CipherInputStream(bais, c);
assertNotNull(cis);
}
use of java.security.SecureRandom in project UltimateRecyclerView by cymcsg.
the class SimpleAnimationAdapter method onBindHeaderViewHolder.
@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
TextView textView = (TextView) viewHolder.itemView.findViewById(R.id.stick_text);
textView.setText(String.valueOf(getItem(position).charAt(0)));
// viewHolder.itemView.setBackgroundColor(Color.parseColor("#AA70DB93"));
viewHolder.itemView.setBackgroundColor(Color.parseColor("#AAffffff"));
ImageView imageView = (ImageView) viewHolder.itemView.findViewById(R.id.stick_img);
SecureRandom imgGen = new SecureRandom();
switch(imgGen.nextInt(3)) {
case 0:
imageView.setImageResource(R.drawable.scn1);
break;
case 1:
imageView.setImageResource(R.drawable.jr13);
break;
case 2:
imageView.setImageResource(R.drawable.jr16);
break;
}
}
use of java.security.SecureRandom in project UltimateRecyclerView by cymcsg.
the class sectionCommonAdapter method onBindHeaderViewHolder.
/**
* this is the section header binding
*
* @param viewHolder section holder
* @param position position
*/
@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
TextView textView = (TextView) viewHolder.itemView.findViewById(R.id.stick_text);
textView.setText(String.valueOf(getItem(hasHeaderView() ? position - 1 : position).charAt(0)));
// viewHolder.itemView.setBackgroundColor(Color.parseColor("#AA70DB93"));
viewHolder.itemView.setBackgroundColor(Color.parseColor("#AAffffff"));
ImageView imageView = (ImageView) viewHolder.itemView.findViewById(R.id.stick_img);
SecureRandom imgGen = new SecureRandom();
switch(imgGen.nextInt(3)) {
case 0:
imageView.setImageResource(R.drawable.scn1);
break;
case 1:
imageView.setImageResource(R.drawable.jr13);
break;
case 2:
imageView.setImageResource(R.drawable.jr16);
break;
}
}
use of java.security.SecureRandom in project UltimateRecyclerView by cymcsg.
the class sectionZeroAdapter method withBindHolder.
/*
@Override
public long generateHeaderId(int position) {
// URLogs.d("position--" + position + " " + getItem(position));
if (getItem(position).length() > 0)
return getItem(position).charAt(0);
else return -1;
}*/
@Override
protected void withBindHolder(itemCommonBinder holder, String data, int position) {
holder.textViewSample.setText(data + "just the sample data");
holder.item_view.setBackgroundColor(Color.parseColor("#AAffffff"));
SecureRandom imgGen = new SecureRandom();
switch(imgGen.nextInt(3)) {
case 0:
holder.imageViewSample.setImageResource(R.drawable.scn1);
break;
case 1:
holder.imageViewSample.setImageResource(R.drawable.jr13);
break;
case 2:
holder.imageViewSample.setImageResource(R.drawable.jr16);
break;
}
}
Aggregations