Tag: text

C#

Convert RTF characters to Greek characters

Let’s see how we can convert RTF(Rich Text Format) characters (RichTextbox C#) to Greek characters. public String Rtf2Greek(String s) { s = s.Replace("’c1", "Α"); s = s.Replace("’c2", "Β"); s = s.Replace("’c3", "Γ"); s = s.Replace("’c4", "Δ"); s = s.Replace("’c5", "Ε"); s = s.Replace("’c6", "Ζ"); s = s.Replace("’c7", "Η"); s = s.Replace("’c8", "Θ"); s = s.Replace("’c9", …

C#

Convert Text into Image with C#

Let’s see how we can convert text into an image using C#: 1 2 3 4 5 6 7 8 9 10 11 12 public Image DrawText(String text) { Image img = new Bitmap(64, 64); Graphics drawing = Graphics.FromImage(img); drawing.Clear(Color.Yellow); Brush textBrush = new SolidBrush(Color.Black); drawing.DrawString(text, new Font(new FontFamily("Trebuchet MS"), 12f), textBrush, 0, 0); drawing.Save(); …

C#, Microsoft Windows

Hashing text with SHA-256 in C#

A simple c# method to produce hashes from plain text using SHA-256 algorithm in visual c#! 1 2 3 4 5 6 public String Hash_SHA256(String plainText) {             byte[] inputBytes = Encoding.UTF8.GetBytes(plainText);             byte[] hashedBytes = (new SHA256CryptoServiceProvider()).ComputeHash(inputBytes);             return BitConverter.ToString(hashedBytes).Replace("-", string.Empty).ToLower(); }public String Hash_SHA256(String plainText) {             byte[] inputBytes = Encoding.UTF8.GetBytes(plainText);             byte[] hashedBytes …