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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:10:46+00:00 2026-05-23T15:10:46+00:00

I am trying to generate a key for encryption: public static final String ENCYT_ALGORITHM

  • 0

I am trying to generate a key for encryption:

public static final String ENCYT_ALGORITHM = "AES/ECB/PKCS7Padding";
public static final String KEY_ALGORITHM = "PBEWITHSHA256AND256BITAES-CBC-BC" ;
//BENCYT_ALGORITHMSE64Encoder encod = new BENCYT_ALGORITHMSE64Encoder();
//BENCYT_ALGORITHMSE64Decoder decod = new BENCYT_ALGORITHMSE64Decoder();

public Encryption(String preMaster,String text,int x){      
    this.preMaster=preMaster;       
    this.text=text.getBytes();
}
public void keyGenerator(){
    KeyGenerator kg = null;
    try {
        kg = KeyGenerator.getInstance("AES");
        secret = kg.generateKey();
    } catch (Exception e) {
        // TODO ENCYT_ALGORITHMuto-generated catch block
        e.printStackTrace();
    }

}

public String preMaster() {

    byte[] keys = null;
    keys = preMaster.getBytes();
    int x = -1;
    int process = 0;
    while (x < keys.length - 2) {
        x++;
        switch (x) {
        case 1:
            process = keys[x + 1] | a ^ c & (d | keys[x] % a);
        case 2:
            process += a | (keys[x] ^ c) & d;
        case 3:
            process += keys[x] ^ (keys[x + 1] / a) % d ^ b;
        default:
            process += keys[x + 1] / (keys[x] ^ c | d);
        }
    }

    byte[] xs = new byte[] { (byte) (process >>> 24),
            (byte) (process >> 16 & 0xff), (byte) (process >> 8 & 0xff),
            (byte) (process & 0xff) };
    preMaster = new String(xs);
    KeyGenerators key = new KeyGenerators(preMaster);
    String toMaster = key.calculateSecurityHash("MD5")
            + key.calculateSecurityHash("MD2")
            + key.calculateSecurityHash("SHA-512");


    return toMaster;
}

public String keyWrapper(){
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); 
    Key SharedKey = secret;
    String key = null;
    char[] preMaster = this.preMaster().toCharArray();
    try {

        byte[]salt={ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; 
        paramSpec = new PBEParameterSpec(salt,256);
        PBEKeySpec keySpec = new PBEKeySpec(preMaster,salt,1024,256);
        SecretKeyFactory factory = SecretKeyFactory.getInstance(KEY_ALGORITHM);
        passwordKey = factory.generateSecret(keySpec);
        Cipher c = Cipher.getInstance(KEY_ALGORITHM);
        c.init(Cipher.WRAP_MODE, passwordKey, paramSpec);
        byte[] wrappedKey = c.wrap(SharedKey);
        key=new String(wrappedKey,"UTF8");
    }catch(Exception e){
        e.printStackTrace();
    }
    return key;
}

And this is the result :

java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at fiador.authentication.util.Encryption.keyWrapper(Encryption.java:101)
at fiador.authentication.util.Encryption.main(Encryption.java:144)
null

I am really desperate … please help me, thanks !

  • 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-23T15:10:47+00:00Added an answer on May 23, 2026 at 3:10 pm

    You have not installed the unlimited strength crypto files, (the default JDK install allows 128 bit keys as documented in http://download.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#AppC).

    Download unlimited strength crypto package here.

    Installation Help

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

Sidebar

Related Questions

Here are my constants //Encryption fields /** Algorithm=RSA Mode=ECB Padding=PKCS1Padding*/ public static final String
I am trying to generate a key using the .net 2.0 PasswordDeriveBytes class. PasswordDeriveBytes
I have a pre-existing public/private key pair for RSA encryption which I need to
Hello everyone I'm trying to convert a PKCS#8 private key that I generate in
I am new to AES encryption but trying to build a solution which: Accepts
I'm trying to import an RSA public/private key pair generated with the Win32 Crypto
I am trying to generate a license key file in the common application data
I am trying to make a program that after it generates a public/private key
I am trying to use gpg generated public keys to do encryption using libgcrypt.
I've been trying to get AES encryption and decryption working for some time in

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.