Bouncy castle no such provider exception

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: 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. no such algorithm: SHA1PRNG for provider BC
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.
What is target sdk version in your android application?

以上就是Bouncy castle no such provider exception的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准