using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Security.Cryptography;

namespace ABC
{
   public class T_IO
    {
        public static void taofile(string noidung, string path)
        {
            string filename_root = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
            //string file_opent = filename_root + "\\CN\\AD.dll";
            string file_opent = path;
            FileStream fs = new FileStream(file_opent, FileMode.Create);
            StreamWriter w = new StreamWriter(fs, Encoding.UTF8);
            w.WriteLine("" + noidung + "");
            w.Flush();
            w.Close();
            fs.Close();
        }
        public static String Read_file(string part)
        {
            FileStream filev = new FileStream(@"" + part + "", FileMode.Open, FileAccess.ReadWrite);
            StreamReader r = new StreamReader(filev);
            string currenline;
            currenline = r.ReadLine();
            filev.Close();
            return currenline;
        }

        public static string mahoachuoi(string chuoi)
        {
            UnicodeEncoding uc = new UnicodeEncoding();
            byte[] hash = uc.GetBytes(chuoi);
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            hash = md5.ComputeHash(hash);
            return Convert.ToBase64String(hash);
        }
    }

}
