0

この無料のソースコードはhttp://www.broccoliproducts.com/softnotebook/desblowfish/BlowFishCrytography.csで見つけました。

プロジェクトにインポートすると、エラーが発生しました。

名前'_assertBufferMatch'は現在のコンテキストに存在しません

名前'_assertBufferMatch'は現在のコンテキストに存在しません

「トレース」という名前は、現在のコンテキストには存在しません

すべてを変更したわけではなく、プロジェクトを再構築するだけで、エラーが発生しました。

このエラーの1つは

        public static void Test()
        {

            // Declaration of local variables
            Random rnd = new Random(1);
            byte[] Key = null;
            byte[] bufferIn = null;
            byte[] bufferOut = null;
            byte[] bufferReturned = null;

            // Loop through the test vectors
            for (int iTest = 0; iTest < TestKeys.Length; iTest++)
            {

                // Load the key and plain-text
                Key = BitConverter.GetBytes(TestKeys[iTest]).Reverse().ToArray();
                bufferIn = BitConverter.GetBytes(TestPlainText[iTest]).Reverse().ToArray();

                // Encrypt with BlowFish
                BlowFishCrytography.BlowFish(bufferIn, ref bufferOut, Key, true);

                // Compare with expected result
                byte[] expectedBufferOut = BitConverter.GetBytes(TestCypherText[iTest]).Reverse().ToArray();
                _assertBufferMatch(expectedBufferOut,bufferOut);

            }

            // Loop through decrypt-encrypt tests
            for (int iTest = 0; iTest < 100*1000; iTest++)
            {

                // Dump progress
                if ((iTest % 100) == 0)
                    Trace.TraceInformation("Test {0}", iTest);

                // Load the key and plain-text
                Key = CreateBlowFishKey(rnd, MAX_KEY_BYTE_LENGTH);

                // Create a buffer of data
                int iLength = rnd.Next(1, 10*1024);
                _softCreateBuffer(ref bufferIn, iLength);
                rnd.NextBytes(bufferIn);

                // Encrypt with BlowFish
                BlowFishCrytography.BlowFishWithPadding(bufferIn, ref bufferOut, Key, true);

                // Decrypt with BlowFish
                BlowFishCrytography.BlowFishWithPadding(bufferOut, ref bufferReturned, Key, false);

                // Compare buffers
                _assertBufferMatch(bufferIn, bufferReturned);

            }

        }
4

1 に答える 1

1

そのコードは、モジュールの単体テストです。テストはSilverlightに含まれているようですが、_assertBufferMatch必要なメソッドはSilverlightでは除外されています。

メソッドとその呼び出しを削除するだけです。デバッグビルドでのみ実行されるため、アルゴリズムが実際に機能する必要はありません。

于 2012-08-23T01:31:30.673 に答える