use of net.viperfish.journal.secureAlgs.BCBlockCipherEncryptor.BCBlockCipherBuilder in project vsDiaryWriter by shilongdai.
the class BlockCiphers method getEncryptor.
public static BlockCipherEncryptor getEncryptor(String cipher, String mode, String padding) {
StringBuilder sb = new StringBuilder();
sb.append(cipher).append("/").append(mode).append("/").append(padding);
String type = sb.toString();
BlockCipherEncryptor bc = cache.get(type);
if (bc == null) {
BlockCipher engine = getBlockCipherEngine(cipher);
BlockCipher modeEngine = wrapBlockCipherMode(engine, mode);
BlockCipherPadding pad = getBlockCipherPadding(padding);
BCBlockCipherBuilder builder = new BCBlockCipherBuilder();
builder.setBlockSize(engine.getBlockSize()).setKeySize(getKeySize(cipher)).setCipher(modeEngine).setPadding(pad);
bc = builder.build();
cache.put(type, bc);
}
return bc;
}
Aggregations