2012-08-23 1 views
0

내가C# Silverlight에서 복어를 사용하는 방법은 무엇입니까?

내 프로젝트에 수입 http://www.broccoliproducts.com/softnotebook/desblowfish/BlowFishCrytography.cs이 무료로 소스 코드를 발견했다, 그것은

이름에 대해 좀 오류를 준 '_assertBufferMatch'현재 컨텍스트

에 존재하지 않는 이름 '_assertBufferMatch'는 현재 컨텍스트에 존재하지 않는

'추적'은 현재 컨텍스트

내가 수정하지 않은 전자에 존재하지 않는 이름 그냥 프로젝트를 다시 빌드하면 오류가 발생합니다.

이 오류 하나

 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); 

      } 

     } 

답변

1

그 코드는 모듈 단위 테스트이다. Silverlight에는 테스트가 포함되어 있지만 Silverlight에는 필요로하는 _assertBufferMatch 메서드가 제외 된 것으로 보입니다.

난 그냥 메서드와 모든 호출을 제거합니다. 디버그 빌드에서만 실행되므로 알고리즘이 실제로 작동하지 않아도됩니다.