Sunday 22 May 2011

SSDP-Tester

I've been looking into UPNP and DLNA which uses SSDP for device discovery, so I put together a win forms tool in C# to monitor SSDP traffic and send discovery requests.



The code can be found here.

Saturday 14 May 2011

RC4

I've been reading up on the PDF file format which lead me to reading about RC4. It looked pretty simple (and is), so I decided to knock up a quick implementation in C# based on the information on Wikipedia. The results can be found here.

To use it, include the namespace

using randomworks;

Then do something like this to turn a plaintext string into a ciphertext int array:

string MyKeyString = "Key";
string MyPlaintext = "Plaintext";

RC4 myRC4 = new RC4();
myRC4.SetKey(MyKeyString);
int[] ciphertext = myRC4.Encrypt(MyPlaintext);

If you want to turn the int array into a nice hex string, do something like this:

StringBuilder sb = new StringBuilder();
for (int i=0; i<ciphertext.length; i++)
{
string s = ciphertext[i].ToString("x2");
sb.Append(s);
}
txtCiphertext = sb.ToString();


To decrypt, just pass the decrypt method an encrypted int array and it'll return a decrypted string.

If you find this useful or notice any mistakes, please let me know.