예제 #1
0
        public byte[] Unprotect(byte[] protectedData)
        {
            protectedData = protectedData.UnGZip();

            var cacheKey = protectedData.ToBase64String();

            return(CachedDecrptedData.GetOrAdd(cacheKey, (key) =>
            {
                var keyLength = protectedData.First();
                var encryptionKeyReference = protectedData.Skip(1).Take(keyLength).ToArray();
                var dataPart = protectedData.Skip(1 + keyLength).ToArray();

                var encryptionKey = DataKeyService.GetEncryptionKey(encryptionKeyReference);
                return CreateProtector(encryptionKey).Unprotect(dataPart);
            }));
        }