Шифрование текста путем перестановки его букв - C#
Формулировка задачи:
Нужно чтоб данный брались из файла и загружались в конце в другой файл
Сама задача: Ребята зашифровывают записки меня местами буквы ( с конца слова записываются)
вот сам код исходный
using System.Linq;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
class Cipher
{
public static string Convert(string text)
{
string[] text_arr = text.Split(' ');
string res = string.Empty;
for (int i = 0; i < text_arr.Length; i++)
{
res += Rev1(text_arr[i]) + " ";
}
return res;
}
static string Rev1(string text)
{
return new string(text.Reverse().ToArray());
}
static void Main(string[] args)
{
string s = "Евстичеева Здравствуй";
string s2 = Cipher.Convert(s);
string s3 = Cipher.Convert(s2);
Console.WriteLine(s3);
Console.WriteLine(s2);
Console.ReadLine();
}
}Решение задачи: «Шифрование текста путем перестановки его букв»
textual
Листинг программы
using System;
using System.IO;
using System.Linq;
using System.Text;
class Cipher
{
public static string Convert(string text)
{
string[] text_arr = text.Split(' ');
string res = string.Empty;
for (int i = 0; i < text_arr.Length; i++)
{
res += Rev1(text_arr[i]) + " ";
}
return res;
}
static string Rev1(string text)
{
return new string(text.Reverse().ToArray());
}
static void Main(string[] args)
{
var s = File.ReadAllText(@"C:\new\1.txt", Encoding.GetEncoding(1251));//чтение из файла
var s2 = Convert(s);
var s3 = Convert(s2);
File.WriteAllText(@"C:\new\1.txt", s3, Encoding.GetEncoding(1251));//запись в файл
Console.WriteLine(s2);
Console.WriteLine(s3);
Console.ReadLine();
}
}