gpt4 book ai didi

org.bouncycastle.crypto.paddings.ZeroBytePadding类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 18:16:31 30 4
gpt4 key购买 nike

本文整理了Java中org.bouncycastle.crypto.paddings.ZeroBytePadding类的一些代码示例,展示了ZeroBytePadding类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZeroBytePadding类的具体详情如下:
包路径:org.bouncycastle.crypto.paddings.ZeroBytePadding
类名称:ZeroBytePadding

ZeroBytePadding介绍

[英]A padder that adds NULL byte padding to a block.
[中]向块中添加空字节填充的填充器。

代码示例

代码示例来源:origin: org.cryptacular/cryptacular

blockCipherPadding = new X923Padding();
} else if ("NULL".equalsIgnoreCase(name) || "Zero".equalsIgnoreCase(name) || "None".equalsIgnoreCase(name)) {
 blockCipherPadding = new ZeroBytePadding();
} else {
 throw new IllegalArgumentException("Invalid padding " + padding);

代码示例来源:origin: com.github.jsendnsca/jsendnsca

public void encrypt(byte[] passiveCheckBytes, byte[] initVector, String password) {
    RijndaelEngine engine = new RijndaelEngine(_keyByteLength * 8);
    PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CFBBlockCipher(engine, 8), new ZeroBytePadding());

    try {
      byte[] sessionKey = new byte[_keyByteLength];
      byte[] passwordBytes = password.getBytes("US-ASCII");
      System.arraycopy(passwordBytes, 0, sessionKey, 0, Math.min(_keyByteLength, passwordBytes.length));

      byte[] iv = new byte[_keyByteLength];
      System.arraycopy(initVector, 0, iv, 0, Math.min(_keyByteLength, initVector.length));

      cipher.init(true, new ParametersWithIV(new KeyParameter(sessionKey), iv));

      byte[] cipherText = new byte[cipher.getOutputSize(passiveCheckBytes.length)];
      int cipherLength = cipher.processBytes(passiveCheckBytes, 0, passiveCheckBytes.length, cipherText, 0);
      cipherLength = cipherLength + cipher.doFinal(cipherText, cipherLength);

      int bytesToCopy = Math.min(passiveCheckBytes.length, cipherLength);
      System.arraycopy(cipherText, 0, passiveCheckBytes, 0, bytesToCopy);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: com.github.jsendnsca/jsendnsca

@Override
public void encrypt(final byte[] passiveCheckBytes, final byte[] initVector, final String password) {
  final BlowfishEngine engine = new BlowfishEngine();
  PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CFBBlockCipher(engine, 8), new ZeroBytePadding());
  try {
    final byte[] passwordBytes = password.getBytes("US-ASCII");
    assertValidPasswordBytesLength(passwordBytes);
    final byte[] sessionKey = new byte[KEY_BYTES_LENGTH];
    System.arraycopy(passwordBytes, 0, sessionKey, 0, Math.min(KEY_BYTES_LENGTH, passwordBytes.length));
    final byte[] iv = new byte[KEY_BYTES_LENGTH];
    System.arraycopy(initVector, 0, iv, 0, Math.min(KEY_BYTES_LENGTH, initVector.length));
    cipher.init(true, new ParametersWithIV(new KeyParameter(sessionKey), iv));
    final byte[] cipherText = new byte[cipher.getOutputSize(passiveCheckBytes.length)];
    int cipherLength = cipher.processBytes(passiveCheckBytes, 0, passiveCheckBytes.length, cipherText, 0);
    cipherLength = cipherLength + cipher.doFinal(cipherText, cipherLength);
    final int bytesToCopy = Math.min(passiveCheckBytes.length, cipherLength);
    System.arraycopy(cipherText, 0, passiveCheckBytes, 0, bytesToCopy);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

cipher = new BufferedGenericBlockCipher(cipher.getUnderlyingCipher(), new ZeroBytePadding());

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com