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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:21:01+00:00 2026-06-15T11:21:01+00:00

I have a function to generate the key using PBE, and I have searched

  • 0

I have a function to generate the key using PBE, and I have searched on internet and find out the following code.

class PBE{
    public PBE(String pw) {
        this.password = pw;
    }
    public SecretKey generateKey() throws NoSuchAlgorithmException, InvalidKeySpecException {
        // make password
        PBEKeySpec keySpec = new PBEKeySpec(this.password.toCharArray(),this.salt,20);
        // create key instance
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        // generate key
        SecretKey key = keyFactory.generateSecret(keySpec);
        return key;
    }
}

And I use this function as

PBE myPBE = new PBE("102a102s");
SecretKey myKey = myPBE.generateKey();
System.out.println(myKey.getEncoded());

However, the output is as the same as my input password. I don’t know why

  • 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-15T11:21:03+00:00Added an answer on June 15, 2026 at 11:21 am

    According to documentation, getEncoded() returns

    an external encoded form for the key used when a standard representation of the key is needed outside the Java Virtual Machine, as when transmitting the key to some other party

    Since you use password-based encryption, external form of the password is the password itself, therefore this behavour is correct.

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

Sidebar

Related Questions

I have the following model defined in .NET: Public Class Request <Key()> Public Property
I have the following code function generate_pdf() { $fdf_data_strings = $this->get_hash_for_pdf(); #$fdf_data_names = array('49a'
I have the following code (generates a quadratic function given the a, b, and
I have a function that generates a key of 4 characters that has to
I have a function to generate an 11 character salt. This salt can include
So, I have two JavaScript functions: function Generate() { //Do something $.ajax({data:{Svc: 'cpMain', Cmd:
I have a function that creates a 2D vector void generate(int n) { vector<
I have a function that generates normal random number matrix having normal distribution using
I have the following javascript method: function 123_test_function(){ } The function is generated by
I have asp.net generated html code. I want execute jQuery click function when user

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.