Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 海绵城堡AES安卓vs弹性城堡AES C#_Java_C#_Android_Encryption - Fatal编程技术网

Java 海绵城堡AES安卓vs弹性城堡AES C#

Java 海绵城堡AES安卓vs弹性城堡AES C#,java,c#,android,encryption,Java,C#,Android,Encryption,我在android java代码项目中看到此代码..: localCipher = Cipher.getInstance("AES/CBC/NoPadding", "SC"); localCipher.init(2, new SecretKeySpec(arrayOfByte1, "AES"), new IvParameterSpec(arrayOfByte2)); byte[] resultarray = new CipherInputStream(cipherDataf, localCiph

我在android java代码项目中看到此代码..:

localCipher = Cipher.getInstance("AES/CBC/NoPadding", "SC");
localCipher.init(2, new SecretKeySpec(arrayOfByte1, "AES"), new IvParameterSpec(arrayOfByte2));
byte[] resultarray = new CipherInputStream(cipherDataf, localCipher);
提供者是SC我指的是spongycastle库:

我尝试使用本机AES net 4和库C#BouncyCastle.Crypto.dll对BouncyCastle进行解密,但没有得到相同的结果

弹跳城堡代码:

KeyParameter key = ParameterUtilities.CreateKeyParameter("AES", arrayOfByte1);
ParametersWithIV withIV = new ParametersWithIV(key, arrayOfByte2);

BufferedCipher c = CipherUtilities.GetCipher("AES/CBC/NoPadding");
c.Init(false, withIV);
resultArray = c.DoFinal(cipherDataf);
AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
aes.Padding = PaddingMode.Zeros;
aes.Mode = CipherMode.CBC;
aes.KeySize = 128;
aes.BlockSize = 128;
aes.Key = arrayOfByte1;
aes.IV = arrayOfByte2;

ICryptoTransform ict = aes.CreateDecryptor();
resultArray = ict.TransformFinalBlock(cipherDataf, 0, cipherDataf.Length);
aes.Clear();
或本机代码网络:

KeyParameter key = ParameterUtilities.CreateKeyParameter("AES", arrayOfByte1);
ParametersWithIV withIV = new ParametersWithIV(key, arrayOfByte2);

BufferedCipher c = CipherUtilities.GetCipher("AES/CBC/NoPadding");
c.Init(false, withIV);
resultArray = c.DoFinal(cipherDataf);
AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
aes.Padding = PaddingMode.Zeros;
aes.Mode = CipherMode.CBC;
aes.KeySize = 128;
aes.BlockSize = 128;
aes.Key = arrayOfByte1;
aes.IV = arrayOfByte2;

ICryptoTransform ict = aes.CreateDecryptor();
resultArray = ict.TransformFinalBlock(cipherDataf, 0, cipherDataf.Length);
aes.Clear();
但我总是解密失败。。c#的等价物是什么


关于

填充模式。无
而不是
填充模式。零
?相同的结果。。。我看到输入解密中的不同数据失败了,或者在其他情况下我有异常:(CryptographicException)->输入数据不是一个完整的块。您是否使用maven的SpongyCastle或某种版本对其进行了测试?我在一个项目中得到了相同的代码,这个项目依赖于一种修改过的SC版本,但它也不适用于它。