简体   繁体   中英

Java encryption TwoFish with Mode ECB

I am trying encrypt and encrypt using Twofish with ECB mode. I tried using the library "gnu.crypto.cipher.Twofish" but it not allow set the mode to ECB. We can use any library or code. Please help. Thanks.

You can use BouncyCastle , it implements the Twofish cipher

The Cipher is implemented as a simple block cipher (effectively ECB) and you are expected to implement the mode of operation. While you require the ECB mode (are you sure??) it seems you don't have to do much more

    Security.addProvider(new BouncyCastleProvider());
    SecretKey sKey = new SecretKeySpec(Hex.decode("8ff6d560edfd395f3a1cbee18bcce3ac"), "Twofish");
    Cipher cipher = Cipher.getInstance("Twofish/ECB/NoPadding","BC");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM