简体   繁体   中英

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.

Please refer this below link,

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

Hope its help full.

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