Category: Security

Simple encryption and decryption of a string in c#

20 August, 2010 (12:32) | Cryptography, Security, Snippets, Programming, C#, Code

Here are some routines which are designed for simple use of Rijndael in C#. I’ve combined a test function in the class for simplicity of showing it’s use.

private static byte[] salt = Encoding.ASCII.GetBytes(”somerandomstuff”);

public static string Encrypt(string plainText, string […]

Implementation of DES in C

16 March, 2008 (23:31) | Cryptography, Security, Code, Computer Science


MD5 in a few lines of Java

12 March, 2007 (10:58) | Cryptography, Java, Security, Snippets

1 import java.security.*;
2 import java.math.*;
3
4 public class MD5 {
5 public static void main(String args[]) throws Exception{
6 String s="This is a test";
[…]

MD5 in one line of C# code.

2 October, 2006 (23:20) | Cryptography, .Net, Security, Snippets

Considering the popularity of using MD5 to hash passwords in a database, I’m litterally baffled as to why Microsoft didn’t include a System.Security.Cryptography.MD5() function. This isn’t quite as nice as that would be, but it gets the job done:
string hash = Convert.ToBase64String(new System.Security.Cryptography.MD5CryptoServiceProvider().
ComputeHash(System.Text.Encoding.Default.GetBytes(SomeString)));

Pretty much every other example I’ve seen are at […]