Yari-Serve.de

I don't know where I'm going, but I'm on my way

Browsing Posts in Snippets

There is only some slow blogging going on recently… So here’s something to fill the Lazyness-Gaps /// <summary> /// Encrypts the specified Text to SHA1 /// </summary> /// <param name="text">The Text to encrypt</param> /// <returns>The SHA1-Encrypted text</returns> public static string EncryptToSHA1(this string text) { SHA1 sha1 = new SHA1CryptoServiceProvider();  byte[] arrayData = Encoding.ASCII.GetBytes(text); byte[] arrayResult [...]

Let’s get a bit more advanced – we’re now converting a WPF-Image to a byte[]. You can then store this byte[] in an MS-SQL Database, for example. /// <summary> /// Converts the specified Image to a byte[] /// </summary> /// <param name="imageToConvert">The Image you wish to convert</param> /// <returns>A Byte[], containing the images Information</returns> public [...]

Let’s go ahead with a little Code-Snippet regarding the FileSize in C#. Sometimes you need to display a “nice file size” – values like 14865343435 Bytes are absolutely useless for Userfriendly Interfaces… /// <summary> /// Creates a nicer FileSize from bytes /// </summary> /// <param name="size">The Size to Parse</param> /// <returns>The converted FileSize, including the [...]