SHARE
TWEET

Untitled

a guest Jun 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static class BaseHelper
  2. {
  3.  public static void EncryptFile(string filename, string output)
  4.  {
  5.   if (File.Exists(filename))
  6.   {
  7.     string b64 = Convert.ToBase64String(EncodingDef(File.ReadAllText(filename)));
  8.     File.WriteAllText(output, b64);
  9.   }
  10. }
  11.  
  12. public static void DecryptFile(string filename, string output)
  13. {
  14.    if (File.Exists(filename))
  15.    {
  16.      byte[] bb = Convert.FromBase64String(filename);
  17.      string save = EncodingUtf8(bb);
  18.      File.WriteAllText(output, save);
  19.    }
  20. }
  21.  
  22.  private static byte[] EncodingDef(string file) =>
  23.  Encoding.Default.GetBytes(file);
  24.  private static string EncodingUtf8(byte[] file) =>
  25.  Encoding.ASCII.GetString(file);
  26. }
  27.      
  28. string filename = "1.txt";
  29. BaseHelper.EncryptFile(filename, "1_enc.txt");
  30. BaseHelper.DecryptFile("1_enc.txt", "1.dec.txt");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top