javaaesaescryptoserviceprovider

is there a Java ECB provider?


Anyone know of a Rijndael-128bit ECB provider in Java???

Also, what's the difference between AES-128bit and ECB? or are they the same? (couldn't find answer any where else online)


Solution

  • ECB is a way of using a block cipher (not a cipher itself). It is not very good. Here is a related question How to choose an AES encryption mode (CBC ECB CTR OCB CFB)?.

    I suspect if you find an implementation of AES (which is the same as Rijndael, by the way), it will be configurable to use ECB.

    Try the following to start you off

    Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "SunJCE");
    Key skeySpec = KeyGenerator.getInstance("AES").generateKey();
    cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
    System.out.println(Arrays.toString(cipher.doFinal(new byte[] { 0, 1, 2, 3 })));