Esempio n. 1
0
 public static void WriteAllEncryptionText(String Path, String cnt)
 {
     using (System.IO.FileStream fs = System.IO.File.Open(Path, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite)) {
         byte[] bs = System.Text.Encoding.UTF8.GetBytes(cnt);
         Pub.Encryption(ref bs);
         fs.Position = 0;
         fs.Write(bs, 0, bs.Length);
     }
 }
Esempio n. 2
0
        public static String ReadAllEncryptionText(String Path)
        {
            String res = "";

            if (System.IO.File.Exists(Path))
            {
                using (System.IO.FileStream fs = System.IO.File.Open(Path, System.IO.FileMode.Open, System.IO.FileAccess.Read)) {
                    byte[] bs = new byte[fs.Length];
                    fs.Read(bs, 0, (int)fs.Length);
                    Pub.Encryption(ref bs);
                    res = System.Text.Encoding.UTF8.GetString(bs);
                    fs.Close();
                }
            }
            else
            {
                WriteAllEncryptionText(Path, "");
            }
            return(res);
        }