code: import java.security.InvalidAlgorithmParameterException;
  import java.security.InvalidKeyException;
  import java.security.NoSuchAlgorithmException;
  import java.security.SecureRandom;
  
  import javax.crypto.BadPaddingException;
  import javax.crypto.Cipher;
  import javax.crypto.IllegalBlockSizeException;
  import javax.crypto.KeyGenerator;
  import javax.crypto.NoSuchPaddingException;
  import javax.crypto.SecretKey;
  import javax.crypto.spec.IvParameterSpec;
  
  public class AES {
  	public void encrypt(String strDataToEncrypt, int keyLength) {
  		try {
  			KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
  			keyGen.initialize(keyLength);
  			KeyPair keyPair = keyGen.generateKeyPair();
  			PublicKey publicKey = keyPair.getPublic();
  
  			Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
  			cipher.init(Cipher.ENCRYPT_MODE, publicKey);
  
  			byte[] byteDataToEncrypt = strDataToEncrypt.getBytes();
  			byte[] byteEncryptedData = cipher.doFinal(byteDataToEncrypt);
  		}
  
  		catch (NoSuchAlgorithmException noSuchAlgo) {
  		}
  
  		catch (NoSuchPaddingException noSuchPad) {
  		}
  
  		catch (InvalidKeyException invalidKey) {
  		}
  
  		catch (BadPaddingException badPadding) {
  		}
  
  		catch (IllegalBlockSizeException illegalBlockSize) {
  		}
  
  		catch (InvalidAlgorithmParameterException invalidParam) {
  		}
  	}
  }
  