Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,990 questions

51,935 answers

573 users

How to decrypt a string from numbers to characters in C#

1 Answer

0 votes
using System;
using System.Text;

public class Program
{
	private static char convert_to_char_code(string str) {
		int num = int.Parse(str);

		return (char)(num + 96);
	}

	private static string decrypt(string s) {
		StringBuilder sb = new StringBuilder();

		int i = 0;
		while (i < s.Length - 2) {
			char ch;
			if (s[i + 2] == '#') {
				ch = (char)convert_to_char_code(s.Substring(i, 2));
				i += 2;
			}
			else {
				ch = (char)convert_to_char_code(s.Substring(i, 1));
			}

			i++;

			sb.Append(ch);
		}

		return sb.ToString();
	}

	public static void Main(string[] args)
	{
		Console.Write(decrypt("10#1426#25#524#"));
	}
}






/*
run:
 
jadzyex
 
*/

 



answered Jul 16, 2023 by avibootz

Related questions

1 answer 123 views
1 answer 115 views
1 answer 117 views
1 answer 125 views
1 answer 129 views
129 views asked Feb 11, 2024 by avibootz
1 answer 194 views
...