Ejemplo n.º 1
0
        static string ManuallyDecrypt(string encryptedString, IEnumerable <string> purposes = null)
        {
            var entropyCreator = new EntropyCreator();
            var entropy        = entropyCreator.CreateEntropy(purposes);
            var protector      = new DataProtector(entropy);

            var cypher   = Convert.FromBase64String(encryptedString);
            var userData = protector.Unprotect(cypher);

            return(Encoding.UTF8.GetString(userData));
        }
Ejemplo n.º 2
0
        static string ManuallyEncrypt(string stringtoEncrypt, IEnumerable <string> purposes = null)
        {
            var entropyCreator = new EntropyCreator();
            var entropy        = entropyCreator.CreateEntropy(purposes);
            var protector      = new DataProtector(entropy);

            var userData = Encoding.UTF8.GetBytes(stringtoEncrypt);
            var cypher   = protector.Protect(userData);

            return(Convert.ToBase64String(cypher));
        }