Vignesh
Vignesh

Reputation: 644

AES Java encryption 16 byte key decryption with Objective-C

In my backend side they have created the encrypted message using AES algorithm with 16 byte key with this piece of code

Key: h7Ui63Mzqj61G87j

    public static String encrypt(String data, byte[] secretKey) throws Exception {
    Key key = generateKey(secretKey);
    Cipher c = Cipher.getInstance(ALGORITHM);
    c.init(Cipher.ENCRYPT_MODE, key);
    byte[] encVal = c.doFinal(data.getBytes());
    String encryptedValue = new BASE64Encoder().encode(encVal);
    if (logger.isDebugEnabled()) {
        logger.debug(String.format("DataToEncrypt: %s, encryptedValue: %s", data, encryptedValue));
    }
    return encryptedValue;
}

But I am unable to decrypt the message with the same key using AES algorithm.

Upvotes: 1

Views: 1886

Answers (1)

ssowri1
ssowri1

Reputation: 1317

Please refer this below link,

https://github.com/callmewhy/why-encrypt

Hope its help full.

Upvotes: 1

Related Questions