congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
IllegalBlockSizeException
Code IndexAdd Tabnine to your IDE (free)

How to use
IllegalBlockSizeException
in
javax.crypto

Best Java code snippets using javax.crypto.IllegalBlockSizeException (Showing top 20 results out of 774)

Refine searchRefine arrow

  • BadPaddingException
  • InvalidKeyException
  • Cipher
  • NoSuchAlgorithmException
  • NoSuchPaddingException
origin: robovm/robovm

  Cipher cipher = Cipher.getInstance(algName);
  if (algParameters == null) {
    cipher.init(Cipher.DECRYPT_MODE, decryptKey);
  } else {
    cipher.init(Cipher.DECRYPT_MODE, decryptKey, algParameters);
  byte[] decryptedData = cipher.doFinal(encryptedData);
  throw new NoSuchAlgorithmException(e.getMessage());
} catch (InvalidAlgorithmParameterException e) {
  throw new NoSuchAlgorithmException(e.getMessage());
} catch (IllegalStateException e) {
  throw new InvalidKeyException(e.getMessage());
} catch (IllegalBlockSizeException e) {
  throw new InvalidKeyException(e.getMessage());
} catch (BadPaddingException e) {
  throw new InvalidKeyException(e.getMessage());
origin: aa112901/remusic

private static byte[] decrypt(byte[] content, String password) {
  try {
    byte[] keyStr = getKey(password);
    SecretKeySpec key = new SecretKeySpec(keyStr, "AES");
    Cipher cipher = Cipher.getInstance(algorithmStr);//algorithmStr
    cipher.init(Cipher.DECRYPT_MODE, key);//   ʼ
    byte[] result = cipher.doFinal(content);
    return result; //
  } catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
  } catch (NoSuchPaddingException e) {
    e.printStackTrace();
  } catch (InvalidKeyException e) {
    e.printStackTrace();
  } catch (IllegalBlockSizeException e) {
    e.printStackTrace();
  } catch (BadPaddingException e) {
    e.printStackTrace();
  }
  return null;
}
origin: robovm/robovm

        NoSuchAlgorithmException, InvalidKeyException {
if (key == null) {
  throw new InvalidKeyException("key == null");
  Cipher cipher = Cipher.getInstance(sealAlg);
  if ((paramsAlg != null) && (paramsAlg.length() != 0)) {
    AlgorithmParameters params =
      AlgorithmParameters.getInstance(paramsAlg);
    params.init(encodedParams);
    cipher.init(Cipher.DECRYPT_MODE, key, params);
  } else {
    cipher.init(Cipher.DECRYPT_MODE, key);
  byte[] serialized = cipher.doFinal(encryptedContent);
  throw new NoSuchAlgorithmException(e.toString());
} catch (InvalidAlgorithmParameterException e) {
  throw new NoSuchAlgorithmException(e.toString());
} catch (IllegalBlockSizeException e) {
  throw new NoSuchAlgorithmException(e.toString());
} catch (BadPaddingException e) {
  throw new NoSuchAlgorithmException(e.toString());
} catch (IllegalStateException  e) {
origin: com.braintreepayments/encryption

public static String encrypt(String data, byte[] aesKey, byte[] iv) throws BraintreeEncryptionException {
  SecretKeySpec key = new SecretKeySpec(aesKey, ALGORITHM);
  Cipher cipher = aesCipher();
  try {
    IvParameterSpec ivParamSpec = new IvParameterSpec(iv);
    cipher.init(Cipher.ENCRYPT_MODE, key, ivParamSpec);
    byte[] encryptedBytes = cipher.doFinal(data.getBytes());
    byte[] buffer = Arrays.copyOf(iv, iv.length + encryptedBytes.length);
    System.arraycopy(encryptedBytes, 0, buffer, iv.length, encryptedBytes.length);
    return new String(Base64.encode(buffer));
  } catch (InvalidKeyException e) {
    throw new BraintreeEncryptionException("Invalid Key: " + e.getMessage());
  } catch (BadPaddingException e) {
    throw new BraintreeEncryptionException("Bad Padding: " + e.getMessage());
  } catch (IllegalBlockSizeException e) {
    throw new BraintreeEncryptionException("Illegal Block Size: " + e.getMessage());
  } catch (InvalidAlgorithmParameterException e) {
    throw new BraintreeEncryptionException("Invalid Algorithm: " + e.getMessage());
  }
}
origin: org.mycontroller.standalone/mycontroller-core

public static String decrypt(String value) {
  try {
    Cipher cipher = Cipher.getInstance(ALGORITHM);
    cipher.init(Cipher.DECRYPT_MODE, generateKey());
    byte[] decryptedValue64 = Base64.decodeBase64(value);
    byte[] decryptedByteValue = cipher.doFinal(decryptedValue64);
    String decryptedValue = new String(decryptedByteValue, "UTF-8");
    return decryptedValue;
  } catch (IllegalBlockSizeException ex) {
    _logger.warn("Exception: '{}'", ex.getMessage());
    _logger.debug("Exception, ", ex);
  } catch (Exception ex) {
    _logger.error("Exception, ", ex);
  }
  return null;
}
origin: com.braintreepayments/encryption

public static String encrypt(byte[] data, String publicKeyString) throws BraintreeEncryptionException {
  Cipher rsa;
  try {
    rsa = Cipher.getInstance(TRANSFORMATION);
    PublicKey publicKey = publicKey(publicKeyString);
    rsa.init(Cipher.ENCRYPT_MODE, publicKey);
    byte[] encodedData = Base64.encode(data);
    byte[] encryptedData = rsa.doFinal(encodedData);
    return new String(Base64.encode(encryptedData));
  } catch (NoSuchAlgorithmException e) {
    throw new BraintreeEncryptionException("No Such Algorithm: " + e.getMessage());
  } catch (NoSuchPaddingException e) {
    throw new BraintreeEncryptionException("No Such Padding: " + e.getMessage());
  } catch (InvalidKeyException e) {
    throw new BraintreeEncryptionException("Invalid Key: " + e.getMessage());
  } catch (IllegalBlockSizeException e) {
    throw new BraintreeEncryptionException("Illegal Block Size: " + e.getMessage());
  } catch (BadPaddingException e) {
    throw new BraintreeEncryptionException("Bad Padding: " + e.getMessage());
  }
}
origin: robovm/robovm

try {
  if (cipher != null) {
    result = cipher.doFinal();
    if (result != null) {
      out.write(result);
  throw new IOException(e.getMessage());
} catch (IllegalBlockSizeException e) {
  throw new IOException(e.getMessage());
} finally {
  if (out != null) {
origin: com.madgag.spongycastle/prov

if (provider == null)
  c = Cipher.getInstance("AES/CCM/NoPadding");
  c = Cipher.getInstance("AES/CCM/NoPadding", provider);
c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(keyBytes, "AES"));
byte[] encOut = c.doFinal(storeData.getEncoded());
throw new NoSuchAlgorithmException(e.toString());
throw new IOException(e.toString());
throw new IOException(e.toString());
throw new IOException(e.toString());
origin: aa112901/remusic

private static byte[] encrypt(byte[] content, byte[] keyBytes) {
  byte[] encryptedText = null;
  if (!isInited) {
    init();
  }
  /**
   *类 SecretKeySpec
   *可以使用此类来根据一个字节数组构造一个 SecretKey,
   *而无须通过一个(基于 provider 的)SecretKeyFactory。
   *此类仅对能表示为一个字节数组并且没有任何与之相关联的钥参数的原始密钥有用
   *构造方法根据给定的字节数组构造一个密钥。
   *此构造方法不检查给定的字节数组是否指定了一个算法的密钥。
   */
  Key key = new SecretKeySpec(keyBytes, "AES");
  try {
    // 用密钥初始化此 cipher。
    cipher.init(Cipher.ENCRYPT_MODE, key);
  } catch (InvalidKeyException e) {
    e.printStackTrace();
  }
  try {
    //按单部分操作加密或解密数据,或者结束一个多部分操作。(不知道神马意思)
    encryptedText = cipher.doFinal(content);
  } catch (IllegalBlockSizeException e) {
    e.printStackTrace();
  } catch (BadPaddingException e) {
    e.printStackTrace();
  }
  return encryptedText;
}
origin: org.tmatesoft.svnkit/svnkit

private byte[] encrypt(byte[] key, byte[] bytes) throws SVNException {
  Cipher ecipher = getCipher(key);
  try {
    byte[] enc = ecipher.doFinal(bytes);
    return enc;
  } catch (IllegalBlockSizeException e) {
    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Invalid block size for DES encryption: {0}", e.getLocalizedMessage());
    SVNErrorManager.error(err, SVNLogType.NETWORK);
  } catch (BadPaddingException e) {
    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Data not padded correctly for DES encryption: {0}", e.getLocalizedMessage());
    SVNErrorManager.error(err, SVNLogType.NETWORK);
  }
  return null;
}

origin: org.bouncycastle/bcprov-debug-jdk15on

  byte[] encOut = c.doFinal(storeData.getEncoded());
  AlgorithmParameters algorithmParameters = c.getParameters();
  byte[] encOut = c.doFinal(storeData.getEncoded());
  PBES2Parameters pbeParams = new PBES2Parameters(pbkdAlgId, new EncryptionScheme(NISTObjectIdentifiers.id_aes256_wrap_pad));
throw new NoSuchAlgorithmException(e.toString());
throw new IOException(e.toString());
throw new IOException(e.toString());
throw new IOException(e.toString());
origin: be.fedict.commons-eid/commons-eid-consumer

  return __verifyNonRepSignature(expectedDigestValue, signatureValue, certificate);
} catch (final InvalidKeyException ikex) {
  LOGGER.warn("invalid key: " + ikex.getMessage(), ikex);
  return false;
} catch (final NoSuchAlgorithmException nsaex) {
  LOGGER.warn("no such algo: " + nsaex.getMessage(), nsaex);
  return false;
} catch (final NoSuchPaddingException nspex) {
  LOGGER.warn("no such padding: " + nspex.getMessage(), nspex);
  return false;
} catch (final BadPaddingException bpex) {
  LOGGER.warn("bad padding: " + bpex.getMessage(), bpex);
  return false;
} catch (final IOException ioex) {
  return false;
} catch (final IllegalBlockSizeException ibex) {
  LOGGER.warn("illegal block size: " + ibex.getMessage(), ibex);
  return false;
origin: ibinti/bugvm

protected byte[] engineWrap(
   Key     key)
 throws IllegalBlockSizeException, InvalidKeyException
 {
   byte[] encoded = key.getEncoded();
   if (encoded == null)
   {
     throw new InvalidKeyException("Cannot wrap key, null encoding.");
   }
   try
   {
     return engineDoFinal(encoded, 0, encoded.length);
   }
   catch (BadPaddingException e)
   {
     throw new IllegalBlockSizeException(e.getMessage());
   }
 }
origin: schwabe/ics-openvpn

@Override
public byte[] getSignedData(String alias, byte[] data) throws RemoteException {
  try {
    return SimpleSigner.signData(data);
  } catch (IOException e) {
    e.printStackTrace();
  } catch (NoSuchPaddingException e) {
    e.printStackTrace();
  } catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
  } catch (IllegalBlockSizeException e) {
    e.printStackTrace();
  } catch (BadPaddingException e) {
    e.printStackTrace();
  } catch (InvalidKeySpecException e) {
    e.printStackTrace();
  } catch (InvalidKeyException e) {
    e.printStackTrace();
  }
  // Something failed, return null
  return null;
}
origin: ibinti/bugvm

@Override
protected byte[] engineWrap(Key key) throws IllegalBlockSizeException, InvalidKeyException {
  try {
    byte[] encoded = key.getEncoded();
    return engineDoFinal(encoded, 0, encoded.length);
  } catch (BadPaddingException e) {
    IllegalBlockSizeException newE = new IllegalBlockSizeException();
    newE.initCause(e);
    throw newE;
  }
}
origin: cloudfoundry-incubator/credhub

 @Override
 public String decrypt(final Key key, final byte[] encryptedValue, final byte[] nonce)
  throws Exception {
  throw new IllegalBlockSizeException("");
 }
});
origin: cloudant/sync-android

  throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
} catch (NoSuchPaddingException e) {
  throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
} catch (NoSuchAlgorithmException e) {
  throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
} catch (IllegalBlockSizeException e) {
  throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
} catch (BadPaddingException e) {
  throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
} catch (InvalidAlgorithmParameterException e) {
  throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
origin: com.pubnub/pubnub

  throw PubNubException.builder().errormsg(e.toString()).build();
} catch (NoSuchPaddingException e) {
  throw PubNubException.builder().errormsg(e.toString()).build();
origin: com.madgag.spongycastle/bcpg-jdk15on

public byte[] encryptKeyData(byte[] key, byte[] keyData, int keyOff, int keyLen)
  throws PGPException
{
  try
  {
    c = helper.createCipher(PGPUtil.getSymmetricCipherName(this.encAlgorithm) + "/CFB/NoPadding");
    c.init(Cipher.ENCRYPT_MODE, JcaJcePGPUtil.makeSymmetricKey(this.encAlgorithm, key), this.random);
    iv = c.getIV();
    return c.doFinal(keyData, keyOff, keyLen);
  }
  catch (IllegalBlockSizeException e)
  {
    throw new PGPException("illegal block size: " + e.getMessage(), e);
  }
  catch (BadPaddingException e)
  {
    throw new PGPException("bad padding: " + e.getMessage(), e);
  }
  catch (InvalidKeyException e)
  {
    throw new PGPException("invalid key: " + e.getMessage(), e);
  }
}
origin: mycontroller-org/mycontroller

public static String decrypt(String value) {
  try {
    Cipher cipher = Cipher.getInstance(ALGORITHM);
    cipher.init(Cipher.DECRYPT_MODE, generateKey());
    byte[] decryptedValue64 = Base64.decodeBase64(value);
    byte[] decryptedByteValue = cipher.doFinal(decryptedValue64);
    String decryptedValue = new String(decryptedByteValue, "UTF-8");
    return decryptedValue;
  } catch (IllegalBlockSizeException ex) {
    _logger.warn("Exception: '{}'", ex.getMessage());
    _logger.debug("Exception, ", ex);
  } catch (Exception ex) {
    _logger.error("Exception, ", ex);
  }
  return null;
}
javax.cryptoIllegalBlockSizeException

Javadoc

The exception, that is thrown when the data length provided to a block cipher does not match the block size of the cipher.

Most used methods

  • getMessage
  • printStackTrace
  • <init>
    Creates a new IllegalBlockSizeException with the specified message.
  • toString
  • getLocalizedMessage
  • initCause

Popular in Java

  • Updating database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • getExternalFilesDir (Context)
  • getApplicationContext (Context)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JComboBox (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now