congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
javax.crypto
Code IndexAdd Tabnine to your IDE (free)

How to use javax.crypto

Best Java code snippets using javax.crypto (Showing top 20 results out of 13,761)

origin: google/guava

private static boolean supportsClone(Mac mac) {
 try {
  mac.clone();
  return true;
 } catch (CloneNotSupportedException e) {
  return false;
 }
}
origin: apache/incubator-dubbo

@Override
public int read(byte[] buffer, int offset, int length)
    throws IOException {
  return _cipherIn.read(buffer, offset, length);
}
origin: apache/incubator-dubbo

@Override
public void write(byte[] buffer, int offset, int length)
    throws IOException {
  _cipherOut.write(buffer, offset, length);
}
origin: jenkinsci/jenkins

public CombinedCipherOutputStream(OutputStream out, Cipher asym, String algorithm) throws IOException, GeneralSecurityException {
  super(out);
  // create a new symmetric cipher key used for this stream
  String keyAlgorithm = getKeyAlgorithm(algorithm);
  SecretKey symKey = KeyGenerator.getInstance(keyAlgorithm).generateKey();
  // place the symmetric key by encrypting it with asymmetric cipher
  out.write(asym.doFinal(symKey.getEncoded()));
  // the rest of the data will be encrypted by this symmetric cipher
  Cipher sym = Secret.getCipher(algorithm);
  sym.init(Cipher.ENCRYPT_MODE,symKey, keyAlgorithm.equals(algorithm) ? null : new IvParameterSpec(symKey.getEncoded()));
  super.out = new CipherOutputStream(out,sym);
}
origin: jenkinsci/jenkins

/**
 * Upgrades a connection with transport encryption by the specified symmetric cipher.
 *
 * @return
 *      A new {@link Connection} object that includes the transport encryption.
 */
public Connection encryptConnection(SecretKey sessionKey, String algorithm) throws IOException, GeneralSecurityException {
  Cipher cout = Cipher.getInstance(algorithm);
  cout.init(Cipher.ENCRYPT_MODE, sessionKey, new IvParameterSpec(sessionKey.getEncoded()));
  CipherOutputStream o = new CipherOutputStream(out, cout);
  Cipher cin = Cipher.getInstance(algorithm);
  cin.init(Cipher.DECRYPT_MODE, sessionKey, new IvParameterSpec(sessionKey.getEncoded()));
  CipherInputStream i = new CipherInputStream(in, cin);
  return new Connection(i,o);
}
origin: jenkinsci/jenkins

private static Cipher toCipher(RSAKey key, int mode) throws GeneralSecurityException {
  Cipher cipher = Cipher.getInstance("RSA");
  cipher.init(mode, (Key)key);
  return cipher;
}
origin: gocd/gocd

private byte[] generateKey() throws NoSuchAlgorithmException {
  KeyGenerator keygen = KeyGenerator.getInstance("AES");
  keygen.init(128);
  byte[] key = keygen.generateKey().getEncoded();
  return key;
}
origin: jenkinsci/jenkins

/**
 * Workaround for JENKINS-6459 / http://java.net/jira/browse/GLASSFISH-11862
 * This method uses specific provider selected via hudson.util.Secret.provider system property
 * to provide a workaround for the above bug where default provide gives an unusable instance.
 * (Glassfish Enterprise users should set value of this property to "SunJCE")
 */
public static Cipher getCipher(String algorithm) throws GeneralSecurityException {
  return PROVIDER != null ? Cipher.getInstance(algorithm, PROVIDER)
              : Cipher.getInstance(algorithm);
}
origin: stackoverflow.com

 /* Derive the key, given password and salt. */
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
KeySpec spec = new PBEKeySpec(password, salt, 65536, 256);
SecretKey tmp = factory.generateSecret(spec);
SecretKey secret = new SecretKeySpec(tmp.getEncoded(), "AES");
origin: apache/incubator-dubbo

@Override
public void write(byte[] buffer, int offset, int length)
    throws IOException {
  _bodyOut.write(buffer, offset, length);
  _mac.update(buffer, offset, length);
}
origin: gocd/gocd

  @Override
  public byte[] createIV() throws NoSuchAlgorithmException {
    KeyGenerator keygen = KeyGenerator.getInstance("AES");
    keygen.init(128);
    return keygen.generateKey().getEncoded();
  }
}
origin: apache/incubator-dubbo

@Override
public int read()
    throws IOException {
  int ch = _bodyIn.read();
  if (ch < 0)
    return ch;
  _mac.update((byte) ch);
  return ch;
}
origin: apache/incubator-dubbo

@Override
public void write(int ch)
    throws IOException {
  _cipherOut.write(ch);
}
origin: apache/incubator-dubbo

@Override
public int read()
    throws IOException {
  return _cipherIn.read();
}
origin: prestodb/presto

private static boolean supportsClone(Mac mac) {
 try {
  mac.clone();
  return true;
 } catch (CloneNotSupportedException e) {
  return false;
 }
}
origin: apache/incubator-dubbo

@Override
public void write(int ch)
    throws IOException {
  _bodyOut.write(ch);
  _mac.update((byte) ch);
}
origin: apache/incubator-dubbo

@Override
public int read(byte[] buffer, int offset, int length)
    throws IOException {
  int len = _bodyIn.read(buffer, offset, length);
  if (len < 0)
    return len;
  _mac.update(buffer, offset, len);
  return len;
}
origin: google/guava

@Override
protected void update(byte[] b, int off, int len) {
 checkNotDone();
 mac.update(b, off, len);
}
origin: google/guava

@Override
protected void update(byte b) {
 checkNotDone();
 mac.update(b);
}
origin: google/guava

@Override
protected void update(byte[] b) {
 checkNotDone();
 mac.update(b);
}
javax.crypto

Most used classes

  • SecretKeySpec
    A key specification for a SecretKey and also a secret key implementation that is provider-independen
  • Cipher
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Mac
    This class provides the public API for Message Authentication Code (MAC) algorithms.
  • IvParameterSpec
    The algorithm parameter specification for an initialization vector.
  • SecretKey
    A cryptographic secret (symmetric) key. This interface is a marker interface to group secret keys an
  • KeyGenerator,
  • PBEKeySpec,
  • CipherInputStream,
  • CipherOutputStream,
  • DESKeySpec,
  • PBEParameterSpec,
  • NoSuchPaddingException,
  • BadPaddingException,
  • KeyAgreement,
  • IllegalBlockSizeException,
  • DHParameterSpec,
  • DESedeKeySpec,
  • DHPublicKey,
  • GCMParameterSpec
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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