내가 암호화 프로세스가 안드로이드 탄력이 성에서 복어 암호화를 사용하여 얼마나 믿을 수 없을만큼 느린 오히려 놀랐습니다 파일. 3MB 파일이 3 분 이상 걸렸습니다. 매우 빠른 다른 알고리즘이 있습니까? 나는 덜 신뢰할만한 보안으로 살 수 있습니다. 여기에 코드가 있습니다. 모든 것은 기억 속에서 이루어집니다. 파일이 없습니다.복어 암호화
private BufferedBlockCipher cipher;
private KeyParameter key;
public Encryption(byte[] key)
{
try
{
BlowfishEngine blowfishEngine = new BlowfishEngine();
CBCBlockCipher cbcBlockCipher = new CBCBlockCipher(blowfishEngine);
cipher = new org.spongycastle.crypto.modes.PaddedBlockCipher(cbcBlockCipher);
this.key = new KeyParameter(key);
}
catch (Exception ex)
{
}
}
public Encryption(String key)
{
this(key.getBytes());
}
public synchronized byte[] Encrypt(byte[] data) throws CryptoException
{
try
{
if (data == null || data.length == 0)
{
return new byte[0];
}
cipher.init(true, key);
return CallCipher(data);
}
catch (Exception ex)
{
return null;
}
}
private byte[] CallCipher(byte[] data) throws CryptoException
{
try
{
int size = cipher.getOutputSize(data.length);
byte[] result = new byte[size];
int olen = cipher.processBytes(data, 0, data.length, result, 0);
olen += cipher.doFinal(result, olen);
if (olen < size)
{
byte[] tmp = new byte[olen];
System.arraycopy(result, 0, tmp, 0, olen);
result = tmp;
}
return result;
}
catch (Exception ex)
{
return null;
}
}
당신은 당신의 코드를 게시하지 않았다. 복어는 올바르게 사용하면 느려서는 안됩니다. BC의 구현이 엉망이거나 비효율적 인 방식으로 사용하고 있습니다. 그리고 왜 AES가 아닌 복어를 선택 했습니까? AES는 강력하고 빠릅니다. – CodesInChaos
OK, 위의 코드를 추가했습니다. Blowfish는 보안 및 사양에 대한 평판이 좋기 때문에 Blowfish를 선택했습니다. 어쩌면 당신 말이 옳고 BC의 실행은 짜증 날 것입니다. – AndroidDev
이 모바일 앱을 사용해 보았는데 AES를 사용합니다. 몇 초 내에 3MB 파일을 암호화했습니다. http://goo.gl/fcOjy 분명히 뭔가 잘못되었습니다. – AndroidDev