I have added the bouncy castle jar file to my application class path in android and in java. This is the code that I've used in both of them. But it doesn't seem to recognize the provider "BC".
SecureRandom sr1=new SecureRandom().getInstance("SHA1PRNG", "BC");
System.out.println(sr1.getProvider());
sr1.setSeed(12);
byte[] a=new byte[0];
sr1.nextBytes(a);
int ai=a[0];
System.out.println(ai);
It throws the following exception in both android and in java:
java.security.NoSuchProviderException: no such provider: BC
How to correct this?
I had not added the provider in the policy file. After doing that I am getting the following exception.
java.security.NoSuchAlgorithmException: no such algorithm: SHA1PRNG for provider
BC<br>
Does it mean that bouncy castle does not provide an implementation of "SHA1PRNG" algorithm? But the whole reason I imported bouncy castle was to have a common provider in both android and in java, so that the sequence of random numbers generated with the same seed are the same in both android and java.