Java到Swift AES加密/解密端口

时间:2019-02-11 22:34:46

标签: swift encryption aes

我在android中开发了一个应用,该应用使用AES / CFB / ZeroBytePadding模式加密和解密字符串,并使用...

private  byte [] hashKey = null;
private Cipher m_encChiper = null;
private Cipher m_decChiper = null;
private final String key = "012345678952";
private final byte initVector[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};

.....

MessageDigest digest = MessageDigest.getInstance("SHA-256");
hashKey = digest.digest(key.getBytes("UTF-8"));

IvParameterSpec iv = new IvParameterSpec(initVector);
SecretKeySpec skeySpec = new SecretKeySpec(hashKey, "AES");

m_encChiper =   Cipher.getInstance("AES/CFB/ZeroBytePadding");//NoPadding
m_encChiper.init(Cipher.ENCRYPT_MODE, skeySpec, iv);

m_decChiper = Cipher.getInstance("AES/CFB/ZeroBytePadding");
m_decChiper.init(Cipher.DECRYPT_MODE, skeySpec, iv);

我尝试使用CryptoSwift在Swift中移植此代码...

有人可以帮助我吗,特别是对于这2行:

IvParameterSpec iv = new IvParameterSpec(initVector);
SecretKeySpec skeySpec = new SecretKeySpec(hashKey, "AES");

非常感谢您的帮助...

0 个答案:

没有答案