C# .NET to Silverlight Class

已取消 已发布的 May 4, 2012 货到付款
已取消 货到付款

I have a c# class I can give you the entire class to work with at some point after I select a worker. The class is encryption and it uses three encrytion options. I need them converted to a silverlight class. The existing code works in .NET for ASP, WInforms etc but I need a version to work in silverlight.

## Deliverables

public unsafe Variable Encode(string algorithm, byte[] key)

{

SymmetricAlgorithm algorithm2;

if (![url removed, login to view])

{

throw new InvalidOperationException("Attempt to Encode a non-binary LOUIS value");

}

CspParameters parameters = new CspParameters

{

Flags = [url removed, login to view]

};

new RSACryptoServiceProvider(parameters);

if (algorithm == "DESCBC")

{

algorithm2 = [url removed, login to view]();

}

else if (algorithm == "AESCBC")

{

algorithm2 = [url removed, login to view]();

}

else if (algorithm == "RC2CBC")

{

algorithm2 = [url removed, login to view]();

}

else

{

if (algorithm != "3DESCBC")

{

throw new InvalidOperationException("Invalid encode algorithm: \"" + algorithm + "\"");

}

algorithm2 = [url removed, login to view]();

}

int length = [url removed, login to view] / 8;

byte[] sourceArray = (byte[])this;

int i = [url removed, login to view];

int inputCount = (i + length) + 4;

byte[] destinationArray = new byte[inputCount];

[url removed, login to view]();

[url removed, login to view]([url removed, login to view], destinationArray, length);

byte[] buffer3 = new byte[length];

for (int j = 0; j != length; j++)

{

buffer3[j] = 0;

}

[url removed, login to view] = buffer3;

[url removed, login to view] = [url removed, login to view];

[url removed, login to view] = [url removed, login to view];

[url removed, login to view] = 8 * length;

[url removed, login to view] = key;

fixed (byte* numRef = &(destinationArray[length]))

{

*((int*)numRef) = [url removed, login to view](i);

}

[url removed, login to view](sourceArray, 0, destinationArray, length + 4, i);

return [url removed, login to view]().TransformFinalBlock(destinationArray, 0, inputCount);

}

public unsafe Variable Decode(string algorithm, byte[] key)

{

SymmetricAlgorithm algorithm2;

byte[] buffer2;

int num4;

if (![url removed, login to view])

{

throw new InvalidOperationException("Attempt to Decode a non-binary LOUIS value");

}

CspParameters parameters = new CspParameters

{

Flags = [url removed, login to view]

};

new RSACryptoServiceProvider(parameters);

if (algorithm == "DESCBC")

{

algorithm2 = [url removed, login to view]();

}

else if (algorithm == "AESCBC")

{

algorithm2 = [url removed, login to view]();

}

else if (algorithm == "RC2CBC")

{

algorithm2 = [url removed, login to view]();

}

else

{

if (algorithm != "3DESCBC")

{

throw new InvalidOperationException("Invalid decode algorithm: \"" + algorithm + "\"");

}

algorithm2 = [url removed, login to view]();

}

int index = [url removed, login to view] / 8;

byte[] inputBuffer = (byte[])this;

int length = [url removed, login to view];

[url removed, login to view] = [url removed, login to view];

[url removed, login to view] = [url removed, login to view];

[url removed, login to view] = 8 * index;

[url removed, login to view] = key;

[url removed, login to view] = new byte[index];

for (int i = 0; i != index; i++)

{

[url removed, login to view][i] = 0;

}

ICryptoTransform transform = [url removed, login to view]();

try

{

buffer2 = [url removed, login to view](inputBuffer, 0, length);

}

catch (Exception)

{

throw new InvalidOperationException("Invalid decode, the source is not encoded with the given algorithm and key");

}

fixed (byte* numRef = &(buffer2[index]))

{

num4 = [url removed, login to view](*((int*)numRef));

}

if ((num4 > (([url removed, login to view] - 4) - index)) || (num4 < ((([url removed, login to view] - 4) - index) - index)))

{

throw new InvalidOperationException("Invalid decode, the source is not encoded with the given algorithm and key");

}

inputBuffer = new byte[num4];

[url removed, login to view](buffer2, index + 4, inputBuffer, 0, num4);

return inputBuffer;

}

public byte[] Hash(string algorithm)

{

HashAlgorithm algorithm2;

if (algorithm == "SHA1")

{

algorithm2 = [url removed, login to view]();

}

else if (algorithm == "SHA256")

{

algorithm2 = [url removed, login to view]();

}

else if (algorithm == "SHA384")

{

algorithm2 = [url removed, login to view]();

}

else if (algorithm == "SHA512")

{

algorithm2 = [url removed, login to view]();

}

else

{

if (algorithm != "MD5")

{

throw new InvalidOperationException("Invalid hash algorithm: \"" + algorithm + "\"");

}

algorithm2 = [url removed, login to view]();

}

if ([url removed, login to view])

{

int length = [url removed, login to view];

Variable variable = this;

byte[] buffer = (byte[])[url removed, login to view]();

return [url removed, login to view](buffer, 8, length * 2);

}

if (![url removed, login to view])

{

throw new InvalidOperationException("Invalid target for hash, must be string or binary");

}

byte[] buffer2 = (byte[])this;

return [url removed, login to view](buffer2, 0, [url removed, login to view]);

}

项目ID: #2738441

关于项目

2个方案 远程项目 活跃的May 4, 2012

有2名威客正在参与此工作的竞标,均价$35/小时

waleedmm

See private message.

$20 USD 在14天内
(51条评论)
4.8
krishnadubey

See private message.

$50.15 USD 在14天内
(3条评论)
1.8