Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7628969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:43:00+00:00 2026-05-31T05:43:00+00:00

I have added the bouncy castle jar file to my application class path in

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:43:02+00:00Added an answer on May 31, 2026 at 5:43 am

    Apparently it doesn’t provide a SecureRandom implementation at all. You can get the system implementation (from Harmony) like this (no need to create an instance to call static method):

    SecureRandom.getInstance("SHA1PRNG")
    

    BouncyCastle has DigestRandomGenerator which could probably used in a similar manner, but may or may not be compatible with the Sun SHA1PRNG (which appears to be proprietary, and really well defined)

    Re: generating OTPs using SecureRandom: SecureRandom with a fixed seed is not the right tool for this. To generate OTPs, you should use a secret key combined with a predictable element (time or a counter). A standard way is using an HMAC as specified by e.g. OATH. Read RFC 4226 for details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added some code which compiles cleanly and have just received this Windows
I have added plain text file to the repository and git decided that it
I have added some settings to my c# application using the configuration editor. There
I have added the COleDropTarget variable to my view class and registered it in
I have added an image to my form's resource file, myForm.resx, and I would
I have this file uploader inside an iframe, but when I embed it to
I have some 3rd party jar files that I want to reference in my
I have added some testers to my Facebook application while it is still in
I have written a variant class, which will be used as the main type
We have a web application that is built on top of a SQL database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.