-1

わかりましたので、文字列入力を受け取り、それを char 配列に変換し、その ASCII を配列に保存します。

Random r = new Random();
        Console.WriteLine("Enter name : ");
        char[] name = Console.ReadLine().ToCharArray();
        byte[] by = new byte [name.Length];
        int[] arr = new int[name.Length];
        FileStream fs = new FileStream("F:\\abc.txt", FileMode.Create, FileAccess.Write);
        for (int i = 0; i < name.Length; i++)
        {
            fs.WriteByte((byte)name[i]);
        }

        for (int i = 0; i <name.Length ; i++)
        {
            by[i] =  ( ((byte )name[i]));

        }
        //for (int i = 0; i < name.Length; i++)
        //{
        //   arr[i] = (byte by[i] (Convert.ToInt16);
        //}
        // fs.WriteByte(48); fs.WriteByte(8); fs.WriteByte(60); fs.WriteByte(80);
        fs.Flush();
        fs.Close();

ASCII を保存する...任意の方法で int に変換し、値に特定の数値を追加できます。私は基本的に暗号化のためにそれを行っており、その一部です。また、追加する数値がランダムに生成される場合...テキストを復号化するときにそれを使用できますか?

4

3 に答える 3