diff --git a/src/keepass2android-app/KeeChallenge.cs b/src/keepass2android-app/KeeChallenge.cs index 3d986028..4bb9373d 100644 --- a/src/keepass2android-app/KeeChallenge.cs +++ b/src/keepass2android-app/KeeChallenge.cs @@ -148,17 +148,13 @@ namespace KeeChallenge { //read the secret from the stream int totalBytesRead = 0; - byte[] buffer = new byte[secret.Length]; - var secretOutputStream = new MemoryStream(secret); - int bytesRead = csDecrypt.Read(buffer, totalBytesRead, secret.Length - totalBytesRead); + int bytesRead = csDecrypt.Read(secret, totalBytesRead, secret.Length - totalBytesRead); while (bytesRead > 0 && totalBytesRead < secret.Length) { - secretOutputStream.Write(buffer, 0, bytesRead); totalBytesRead += bytesRead; - bytesRead = csDecrypt.Read(buffer, totalBytesRead, secret.Length - totalBytesRead); + bytesRead = csDecrypt.Read(secret, totalBytesRead, secret.Length - totalBytesRead); } - secretOutputStream.Close(); csDecrypt.Close(); }