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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:02:06+00:00 2026-05-14T03:02:06+00:00

The following code is a try to encrypt data using AES with asymmetric key:

  • 0

The following code is a try to encrypt data using AES with asymmetric key:

import java.io.OutputStream;
import java.math.BigInteger;
import java.security.Key;
import java.security.KeyFactory;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;

import javax.crypto.Cipher;

public class AsyncronousKeyTest {

    private final Cipher cipher;
    private final KeyFactory keyFactory;
    private final RSAPrivateKey privKey;

    private AsyncronousKeyTest() throws Exception {
 cipher = Cipher.getInstance("AES/CBC/NoPaddin", "BC");
 keyFactory = KeyFactory.getInstance("AES", "BC");

 // create the keys

 RSAPrivateKeySpec privKeySpec = new RSAPrivateKeySpec(new BigInteger(
  "d46f473a2d746537de2056ae3092c451", 16), new BigInteger("57791d5430d593164082036ad8b29fb1",
  16));
 privKey = (RSAPrivateKey) keyFactory.generatePrivate(privKeySpec);

    }

    public void generateAuthorizationAct(OutputStream outputStream) throws Exception {

 KeyFactory keyFactory = KeyFactory.getInstance("AES", "BC");
 RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(new BigInteger("d46f473a2d746537de2056ae3092c451",
  16), new BigInteger("11", 16));
 RSAPublicKey pubKey = (RSAPublicKey) keyFactory.generatePublic(pubKeySpec);

 byte[] data = new byte[] {0x01};

 byte[] encrypted = encryptAO(pubKey, data);
 outputStream.write(encrypted);
    }

    /** Encrypt the AuthorizationObject. */
    public byte[] encryptAO(Key pubKey, byte[] data) throws Exception {
 cipher.init(Cipher.ENCRYPT_MODE, pubKey);
 byte[] cipherText = cipher.doFinal(data);
 return cipherText;
    }

    public byte[] decrypt(byte[] cipherText) throws Exception {
 cipher.init(Cipher.DECRYPT_MODE, privKey);
 byte[] decyptedData = cipher.doFinal(cipherText);
 return decyptedData;

    }

    public static void main(String[] args) throws Exception {
 System.out.println("start");

 AsyncronousKeyTest auth = new AsyncronousKeyTest();
 auth.generateAuthorizationAct(System.out);

 System.out.println("done");
    }

}

but at line

cipher = Cipher.getInstance("AES/CBC/NoPaddin", "BC");

it throws

NoSuchPaddingException: Padding NoPaddin unknown.

What is this? And how to solve?

  • 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-14T03:02:07+00:00Added an answer on May 14, 2026 at 3:02 am

    “Padding” is not “Paddin”. The “g” matters.

    Also, “encrypting data with AES with asymmetric key” makes no sense. A RSA key, as its name says, is for RSA, not for AES. AES uses a symmetric key, namely an array of (arbitrary) bytes of length 16, 24 or 32 bytes. A RSA key is a mathematical objects consisting of two integers, one of which being quite big (typically 1024 bits).

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

Sidebar

Ask A Question

Stats

  • Questions 515k
  • Answers 515k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This does what you specifically asked for, removing the border… May 16, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer Try taking a look at OVal and others implementors of… May 16, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer Myself, I would rather chew my leg of then go… May 16, 2026 at 6:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Consider the following code: try { using(TransactionScope) { Process.Start(SQLInstaller.EXE); throw new Exception(); Commit(); }
Try the following code: myListener = new Object(); myListener.onKeyUp = function() { if (Key.isDown(Key.CONTROL)
I am using the following code to get some info about my PCIController try
I have the following code to encrypt a value (listed below). Now I would
Mornin', I'm trying to just get basic encryption working using System.Security.Cryptography.RjindaelManaged. I have google
I'm trying to understand why the following code results in the encrypted byte array
I have a code that does compression, encryption and checksum on a File Outputstream.
To save a file i defined the following method public int encrypt(String fileName, String
The following code is good for uploading text files, but it fails to upload
The following code works fine until I upgrade to .NET 4 (x64) namespace CrashME

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.