Java 8 Cipher - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Cipher class.

This code example shows how to use the following methods: doFinal, init
	     
		AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);
    	 
		SecretKeySpec skeySpec = new SecretKeySpec(m_dbKeyData, "AES");  
		m_encryptCipher = Cipher.getInstance("AES/CBC/NoPadding");  
		m_encryptCipher.init(Cipher.ENCRYPT_MODE, skeySpec, paramSpec);
 
		m_decryptCipher = Cipher.getInstance("AES/CBC/NoPadding");  
		m_decryptCipher.init(Cipher.DECRYPT_MODE, skeySpec, paramSpec);
		 
        Logger.T(TAG, "RhoCrypt context initialized for partition: " + szPartition);
    } 
 
    public boolean db_encrypt( String szPartition, ByteBuffer dataIn, ByteBuffer dataOut )
    { 
        try 
        { 
            initContext(szPartition);
 
            dataOut.rewind();

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: doFinal, init, wrap
 
        try 
        { 
            if (algParams != null)
            { 
                keyEncryptionCipher.init(Cipher.WRAP_MODE, publicKey, algParams, random);
            } 
            else 
            { 
                keyEncryptionCipher.init(Cipher.WRAP_MODE, publicKey, random);
            } 
            encryptedKeyBytes = keyEncryptionCipher.wrap(OperatorUtils.getJceKey(encryptionKey));
        } 
        catch (InvalidKeyException e)
        { 
        } 
        catch (GeneralSecurityException e)
        { 
        } 
        catch (IllegalStateException e)

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: doFinal, init, unwrap
 
            try 
            { 
                if (algParams != null)
                { 
                    keyCipher.init(Cipher.UNWRAP_MODE, privKey, algParams);
                } 
                else 
                { 
                    keyCipher.init(Cipher.UNWRAP_MODE, privKey);
                } 
                sKey = keyCipher.unwrap(encryptedKey, helper.getKeyAlgorithmName(encryptedKeyAlgorithm.getAlgorithm()), Cipher.SECRET_KEY);
            } 
            catch (GeneralSecurityException e)
            { 
            } 
            catch (IllegalStateException e)
            { 
            } 
            catch (UnsupportedOperationException e)

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: doFinal, getParameters, init, update
        // stream test 
        // 
        IEKeySpec   c1Key = new IEKeySpec(aPriv, bPub);
        IEKeySpec   c2Key = new IEKeySpec(bPriv, aPub);
 
        c1.init(Cipher.ENCRYPT_MODE, c1Key);
 
        AlgorithmParameters param = c1.getParameters();
 
        c2.init(Cipher.DECRYPT_MODE, c2Key, param);
 
        byte[] message = Hex.decode("1234567890abcdef");
 
        byte[] out1 = c1.doFinal(message, 0, message.length);
 
        byte[] out2 = c2.doFinal(out1, 0, out1.length);
 
        if (!areEqual(out2, message))
        { 
            fail("stream cipher test failed"); 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getAlgorithm, init, wrap
 
        try 
        { 
            IvParameterSpec ivSpec = new IvParameterSpec(ASN1OctetString.getInstance(keyEncryptionAlgorithm.getParameters()).getOctets());
 
            keyEncryptionCipher.init(Cipher.WRAP_MODE, new SecretKeySpec(derivedKey, keyEncryptionCipher.getAlgorithm()), ivSpec);
 
            return keyEncryptionCipher.wrap(contentEncryptionKeySpec);
        } 
        catch (GeneralSecurityException e)
        { 
            throw new CMSException("cannot process content encryption key: " + e.getMessage(), e);
        } 
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 Cipher Questions & Answers:

See Code Examples for Java 8 Cipher Methods: