I had found this free source code in http://www.broccoliproducts.com/softnotebook/desblowfish/BlowFishCrytography.cs
When I imported it in my project, it gave me some error about
The name ‘_assertBufferMatch’ does not exist in the current context
The name ‘_assertBufferMatch’ does not exist in the current context
The name ‘Trace’ does not exist in the current context
I hadn’t modified everything, just rebuild the project, then the error occurred .
this error one is
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);
}
}
That code is a unit test for the module. It seems that the test is included for Silverlight, but the
_assertBufferMatchmethod it needs is excluded for Silverlight.I would just remove the method and any calls to it. It will only run in debug builds, so it won’t be necessary for the algorithm to actually work.