ios - AES/cbc/pkcs5padding加密IOS

标签 ios aes

我在android中使用了AES算法进行加密。 以下代码我们已用于加密。

String seed = "somekey";
        Key key = null;
        // 128 bit key
        byte[] byteKey = seed.substring(0, 16).getBytes("UTF-8");
        key = new SecretKeySpec(byteKey, "AES");

        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(
                new byte[16]));
        byte[] encValue = cipher.doFinal(pValue.getBytes());
        encryptedText = new BASE64Encoder().encode(encValue);

谁能提供IOS的上述逻辑

提前致谢。

最佳答案

它同时适用于 android 和:

#define FBENCRYPT_KEY_SIZE      kCCKeySizeAES128

改为:

#define FBENCRYPT_KEY_SIZE      kCCKeySizeAES256

关于ios - AES/cbc/pkcs5padding加密IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31738888/

相关文章:

ios - 尝试从核心数据中获取数据时应用程序崩溃

ios - App Store Connect 拒绝应用发布,说 "Missing Purpose String in Info.plist",但该应用不需要这些权限

java - java 1.4 中的 Arrays.copyOf

javascript - 使用 AES/ECB/NoPadding 和 base 64 和 crypto-js 库实现的不正确的解密字符串

c# - 我应该使用 System.Security.Cryptography 命名空间中的哪个 AES 类?

ios - 如何在 facebook ios sdk 中处理 session

ios - NSOperation KVO 已完成

Java AES CBC解密

ios - 调试合并.swiftmodule : segmentation fault: 11

Python - 连接字节到字符串,切断字符串中的一些字节