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 9087921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:48:24+00:00 2026-06-16T21:48:24+00:00

I am using following code snippet for getting factory instance of specified algorithm. But

  • 0

I am using following code snippet for getting factory instance of specified algorithm. But it is throwing a java.security.NoSuchAlgorithmException. I am using this in my java project with jre1.6.

Is it require any external library(jar)? The same code when I tried in my Android app, it’s working fine.

try {
    SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEWITHMD5AND256BITAES-CBC-OPENSSL");
} catch (Exception e) {
    e.printStackTrace();
}

Provider[] providers = Security.getProviders();
if (null == providers) {
    System.out.println("Providers are not available.");
    return;
}

for (Provider provider : providers) {
    System.out.println("Provider: " + provider.getName());
    Set<Provider.Service> services = provider.getServices();
    for (Provider.Service service : services) {
        System.out.println("\tAlgorithm: " + service.getAlgorithm());
    }
}

try {
    SecretKeyFactory factory = SecretKeyFactory.getInstance(providers[0].getServices().iterator().next().getAlgorithm());
    if (null == factory) {
        System.out.println("Getting instance of specified algorithm failed.");
    } else {
        System.out.println("Success.");
    }
} catch (Exception e) {
    e.printStackTrace();
}

Above is edited code and is throwing following exception:

java.security.NoSuchAlgorithmException: SHA1PRNG SecretKeyFactory not available
    at javax.crypto.SecretKeyFactory.<init>(DashoA13*..)
    at javax.crypto.SecretKeyFactory.getInstance(DashoA13*..)
  • 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-06-16T21:48:25+00:00Added an answer on June 16, 2026 at 9:48 pm

    "PBEWITHMD5AND256BITAES-CBC-OPENSSL" is part of the Bouncy Castle provider, you may have to download that library to use it on Java SE. Don’t forget to download the unlimited strength jurisdiction policy files too.

    As for the second exception, if you just ask the algorithm of the first service of the first provider, you get get an algorithm that is only valid for a specific type. In this case it is usable only for SecureRandom, not for SecretKeyFactory as you would have found if you had replaced .getAlgorithm() with .getType().

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

Sidebar

Related Questions

I am using the following code snippet to calculate a total price. This works
I have the following code snippet: using (SPSite site = new SPSite(this.ListAddress)) { using
I am using following code snippet, but its not working :-( //First four characters
I'm getting error using the following code snippet jQuery(document).ready(function() { jQuery.ajax({ url: url, type:
I'm using the following code-snippet extensively in my model templates. <div class=control-group> @Html.LabelFor(model =>
From the book Groovy and Grails recipes I'm using the following code snippet: String
Here is the following code-snippet I'm using in my Google Spreadsheet onEdit() function: else
The following is a Python code snippet using the ast and symtable packages. I
I have the following snippet of code (I'm using jQuery 1.4.2): $.post('/Ads/GetAdStatsRow/', { 'ad_id':
I am trying to post some java code snippets on wordpress.com using the following

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.