當前位置: 首頁>>代碼示例>>Java>>正文


Java CipherOutputStream類代碼示例

本文整理匯總了Java中org.spongycastle.crypto.io.CipherOutputStream的典型用法代碼示例。如果您正苦於以下問題:Java CipherOutputStream類的具體用法?Java CipherOutputStream怎麽用?Java CipherOutputStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CipherOutputStream類屬於org.spongycastle.crypto.io包,在下文中一共展示了CipherOutputStream類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeAndRead

import org.spongycastle.crypto.io.CipherOutputStream; //導入依賴的package包/類
private byte[] writeAndRead(byte[] data, byte[] key) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    CipherOutputStream outStream = IoUtil.encryptTo(baos, key);
    outStream.write(data);
    outStream.close();

    byte[] cipherText = baos.toByteArray();

    ByteArrayInputStream bais = new ByteArrayInputStream(cipherText);
    CipherInputStream inStream = IoUtil.decryptFrom(bais, key);

    byte[] result = ByteStreams.toByteArray(inStream);

    inStream.close();
    return result;
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:17,代碼來源:IoUtilTest.java

示例2: encryptTo

import org.spongycastle.crypto.io.CipherOutputStream; //導入依賴的package包/類
static CipherOutputStream encryptTo(OutputStream stream, byte[] key) throws IOException {
    byte[] randomIv = new byte[BLOCK_SIZE];
    RANDOM.nextBytes(randomIv);

    stream.write(randomIv);
    return new CipherOutputStream(
            stream,
            createAes128CtrPkcs7PaddingCipher(true, randomIv, key));
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:10,代碼來源:IoUtil.java

示例3: upsertCredential

import org.spongycastle.crypto.io.CipherOutputStream; //導入依賴的package包/類
/**
 * Writes (or overwrites) the provided credential to the store. Requires that the credential
 * store is unlocked. May be empty.
 * @throws IOException if the credential could not be written.
 */
public void upsertCredential(Credential credential) throws IOException {
    checkUnlocked();

    initAuthDomainDir(credential.getAuthDomain().getUri());
    File credentialFile = getCredentialFile(credential);
    CipherOutputStream cipherOutputStream = IoUtil.encryptTo(credentialFile, mKey);
    try {
        credential.writeTo(cipherOutputStream);
    } finally {
        IoUtil.closeQuietly(cipherOutputStream, LOG_TAG);
    }
    upsertHint(credential);
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:19,代碼來源:CredentialStorage.java

示例4: generateKeyTestFile

import org.spongycastle.crypto.io.CipherOutputStream; //導入依賴的package包/類
private void generateKeyTestFile() throws IOException {
    CipherOutputStream stream = null;
    try {
        stream = IoUtil.encryptTo(getKeyTestFile(), mKey);
        stream.write(KEY_VERIFICATION_BYTES);
    } finally {
        IoUtil.closeQuietly(stream, LOG_TAG);
    }
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:10,代碼來源:CredentialStorage.java

示例5: getEncryptedOutputStream

import org.spongycastle.crypto.io.CipherOutputStream; //導入依賴的package包/類
/**
 * Create an encrypted output stream from an unencrypted output stream
 */
public static OutputStream getEncryptedOutputStream (OutputStream decryptedOutputStream, byte[] keyData, byte[] ivData) {
    final ParametersWithIV keyAndIV = new ParametersWithIV(new KeyParameter(keyData), ivData);
    PaddedBufferedBlockCipher pbbc = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    pbbc.init(true, keyAndIV);
    return new CipherOutputStream(decryptedOutputStream, pbbc);
}
 
開發者ID:jorabin,項目名稱:KeePassJava2,代碼行數:10,代碼來源:Encryption.java


注:本文中的org.spongycastle.crypto.io.CipherOutputStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。