using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;

namespace co_zpracování
{
    internal static class Krypt
    {
        private static byte[] Entropie = {1, 6, 7, 2, 0};

        internal static string Kryptuj(string text)
        {
            byte[] secret = System.Text.Encoding.Unicode.GetBytes(text);

            byte[] kod = ProtectedData.Protect(secret, Entropie, DataProtectionScope.CurrentUser);

            return Convert.ToBase64String(kod);
        }

        internal static string Dekryptuj(string kod)
        {
            byte[] secret = Convert.FromBase64String(kod);

            byte[] odheslovano = ProtectedData.Unprotect(secret, Entropie, DataProtectionScope.CurrentUser);

            return Encoding.Unicode.GetString(odheslovano);
        }
    }
}
