Пример #1
0
        public string Encrypt(string inputToEncrypt, IEnumerable <string> purposes = null)
        {
            if (string.IsNullOrEmpty(inputToEncrypt))
            {
                throw new ArgumentNullException("inputToEncrypt");
            }

            var entropy       = _entropyCreator.CreateEntropy(purposes);
            var dataProtector = _dataProtectorFactory.Create(entropy);

            var userData = Encoding.UTF8.GetBytes(inputToEncrypt);
            var cypher   = dataProtector.Protect(userData);

            return(Convert.ToBase64String(cypher));
        }
Пример #2
0
 void ConfigureDataProtectorCreator_ToReturn(byte[] entropy, IDataProtector dataProtector)
 {
     A.CallTo(() => _dataProtectorFactory.Create(A <byte[]> .That.IsSameSequenceAs(entropy)))
     .Returns(dataProtector);
 }