Having girls/womans in a dev team is always fun. Yes, you have to wash your body more than every Visual Studio release.
But girls have also different way of looking at the problem. I had this experience in a training last week. There’s one girl in dev team. While showing how to work with Cryptography namespace I was creating simple method for SHA1 hash. Saying, that’s pretty easy to create SHA1 hash in a couple of lines I got a question (yes, from the girl
), whether it’s possible to do it in one row, to make code more compact and show that’s double pretty easy. And it really is:
label1.Text = string.Join(string.Empty, new SHA1Managed().ComputeHash(Encoding.Unicode.GetBytes(textBox1.Text)).Select(_ => _.ToString()).ToArray());
It’s not the most readable code, but as a helper function somewhere …


#1 by T on 8.6.2009 - 17:09
Quote
label1.Text = BitConverter.ToString(new SHA1Managed().ComputeHash(Encoding.Unicode.GetBytes(textBox1.Text)));
#2 by Petr Vones on 11.6.2009 - 01:17
Quote
Jen drobna poznamka. Na jeden radek je to sice krasne efektni, lec naprosto spatne, zvlaste ma-li to slouzit jako ukazka spravneho pristupu. Trida SHA1Managed totiz implementuje IDisposable interface, takze by se melo volat Dispose(). Ze ho implementace v .NET 3.5 zrovna nepouziva ? To je irelevantni. V pristi verzi se to treba muze zmenit: http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha1managed.dispose(VS.100).aspx
#3 by cincura.net on 11.6.2009 - 10:05
Quote
S Dispose by to nebylo na jeden radek. A neni to ukazka spravneho pristupu.
A jak si spravne poznamenal, aktualne to nic nedela.
#4 by Petr Vones on 11.6.2009 - 12:26
Quote
Nebylo, protoze to nejde. Presne temito mylnymi predpoklady (“ze to ted nic nedela”) vznika typicky zpraseny kod, ktery je v pripade problemu pak nutne slozite hledat.
Pingback: Blog Jitka Dařbujanová - tvorba www, programování, webdesign, zend framework » Blog Archive » Having boys/men in a dev team is … ;)