Mengenkripsi Pesan Dengan Manipulasi String C# Posted by Unknown on January 14, 2015 Get link Facebook X Pinterest Email Other Apps using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MODUL6_6 { class Program { static void Main(string[] args) { string kalimat; int pergeseran; int[] ascGeser = new int[0]; Console.Write("Input Suatu pesan="); kalimat = Console.ReadLine(); do { Console.Write("Besar Pergeseran="); pergeseran = Convert.ToInt32(Console.ReadLine()); if (pergeseran < 1) Console.Write("pergeseran harus lebih besar >0!!\n"); } while (pergeseran < 1); Console.WriteLine(""); Console.Write("pesan sebelum pergeseran= {0}\n", kalimat); Console.Write("pesan sebelum pergeseran (dalam ASCII)="); for (int i = 0; i < kalimat.Length; i++) { Console.Write("{0} ", Convert.ToInt32(kalimat[i])); Array.Resize(ref ascGeser, ascGeser.Length + 1); ascGeser[ascGeser.GetUpperBound(0)] = Convert.ToInt32(kalimat[i]) + pergeseran % 256; } kalimat = ""; for (int i = 0; i <= ascGeser.GetUpperBound(0); i++) { kalimat += Convert.ToChar(ascGeser[i]); } Console.WriteLine(""); Console.Write("\npesan sesudah pergeseran={0}", kalimat); Console.Write("\npesan sesudah pergeseran (dalam ASCII) = "); foreach (int i in ascGeser) { Console.Write("{0} ", i); } Console.Write("\n"); Console.ReadKey(); } } } Comments
Comments
Post a Comment