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

  • Home
  • SEARCH
  • 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 4080666
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:57:34+00:00 2026-05-20T17:57:34+00:00

Can I use every possible String to create a new SecretKeySpec ? Or will

  • 0

Can I use every possible String to create a new SecretKeySpec? Or will it weaken the entire encryption?

byte[] raw = password.getBytes();
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
  • 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-20T17:57:35+00:00Added an answer on May 20, 2026 at 5:57 pm

    It’s going to be relatively weak to use the password bytes directly. At the very least you’ll want to run them through a strong hash. And throw in a salt, some array of bytes that you can reproduce for the scenario (either static for your app or better something like a fixed user id).

    MessageDigest digest = MessageDigest.getInstance("SHA-256");
    digest.update(password.getBytes());
    digest.update(salt);
    byte[] raw = digest.digest();
    

    If you really want to make it harder to brute force the password, you could make the hashing more complicated. This for example will only add a few tens of milliseconds for legitimate use cases, however it’ll significantly slow down a brute force attack:

    for (int i = 0; i < 34000; i++) {
        digest.reset();
        digest.update(raw);
        raw = digest.digest();
    }
    

    Ideally you make sure the password is strong as well (length, complexity, mix of upper/lower/number characters). If it’s a simple word or short enough then the attack is still going to be easy. Don’t trust the obscurity of this hashing either, it doesn’t make it any safer. It’s use of strong passwords and strong hashing that matter.

    To get the full benefit of 128-bit AES the password would need to be around 20 characters long, however 8 to 12 will probably suffice for the majority of concerns. If you’re working for my bank please use 20 or more though.

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

Sidebar

Related Questions

I want to create a display template for string properties only, and use default
I can't really ever think of a time when I would use git merge
I can use FireFox and FireBug, in a pane, I can open a .css
I can use the PRINT statement in a stored procedure to debug my code.
I can use stat() to figure out what permissions the owner, group, or others
We can use solr range query like: http://localhost:8983/solr/select?q=queryStr&fq=x:[10 TO 100] AND y:[20 TO 300]
You can use the Filter property of a BindingSource to do SQL like filtering.
I can use ipcs(1) to list out the active shared memory objects on a
I can use the MS Word ActiveX control in order to access some parameters
I can use TypeDescriptor.AddAttributes to add an attribute to a type in runtime. How

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.