Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class BaseHelper
- {
- public static void EncryptFile(string filename, string output)
- {
- if (File.Exists(filename))
- {
- string b64 = Convert.ToBase64String(EncodingDef(File.ReadAllText(filename)));
- File.WriteAllText(output, b64);
- }
- }
- public static void DecryptFile(string filename, string output)
- {
- if (File.Exists(filename))
- {
- byte[] bb = Convert.FromBase64String(filename);
- string save = EncodingUtf8(bb);
- File.WriteAllText(output, save);
- }
- }
- private static byte[] EncodingDef(string file) =>
- Encoding.Default.GetBytes(file);
- private static string EncodingUtf8(byte[] file) =>
- Encoding.ASCII.GetString(file);
- }
- string filename = "1.txt";
- BaseHelper.EncryptFile(filename, "1_enc.txt");
- BaseHelper.DecryptFile("1_enc.txt", "1.dec.txt");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement