21 Temmuz 2010 Çarşamba

Java, Hashing via MD5

public static byte[] getKeyedDigest(byte[] buffer, byte[] key) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(buffer);
return md5.digest(key);
} catch (NoSuchAlgorithmException e) {
}
return null;
}

20 Temmuz 2010 Salı

create pdf pages in c#

Document myDocument = new Document(PageSize.A4.Rotate());
PdfWriter.GetInstance(myDocument, new FileStream(@"C:\Users\earabur\Documents\Visual Studio 2008\Projects\Project1\SaveAsPDF\dosyalar\Osman.pdf", FileMode.Create));

myDocument.Open();
myDocument.Add(new Paragraph("this is my first\n pdf2"));

myDocument.Close();


itextsharp.dll : http://sourceforge.net/projects/itextsharp/

16 Temmuz 2010 Cuma

SHA1 ile hashleme

public static string ComputeHash(string inputString)
{
string retval = string.Empty;
System.Security.Cryptography.SHA1 sha1 = System.Security.Cryptography.SHA1.Create();
byte[] plainbytes = System.Text.Encoding.UTF8.GetBytes(inputString);
retval = Convert.ToBase64String(sha1.ComputeHash(plainbytes));
sha1 = null;
return retval;
}