예제 #1
0
        public async Task<string> Decrypt(string encryptedPremiumToken, string apiKey) {
            var aes = new Aes();
            var sha1 = new SHA1Hash();

            var keyHash = await sha1.GetHashAsync(apiKey).ConfigureAwait(false);
            var unencryptedPremiumToken =
                await aes.DecryptAsync(encryptedPremiumToken, keyHash).ConfigureAwait(false);
            return unencryptedPremiumToken;
        }
예제 #2
0
        public async Task <string> Decrypt(string encryptedPremiumToken, string apiKey)
        {
            var aes  = new Aes();
            var sha1 = new SHA1Hash();

            var keyHash = await sha1.GetHashAsync(apiKey).ConfigureAwait(false);

            var unencryptedPremiumToken =
                await aes.DecryptAsync(encryptedPremiumToken, keyHash).ConfigureAwait(false);

            return(unencryptedPremiumToken);
        }
예제 #3
0
            async Task <PremiumAccessToken> GetPremiumTokenInternal(string encryptedPremiumToken, string apiKey)
            {
                var premiumToken = DomainEvilGlobal.Settings.AccountOptions.UserInfo.Token;

                try {
                    var premiumCached = _firstCompleted && premiumToken.IsPremium() &&
                                        premiumToken.IsValidInNearFuture();
                    if (!premiumCached)
                    {
                        var aes  = new Aes();
                        var sha1 = new SHA1Hash();

                        var keyHash = await sha1.GetHashAsync(apiKey).ConfigureAwait(false);

                        var unencryptedPremiumToken =
                            await aes.DecryptAsync(encryptedPremiumToken, keyHash).ConfigureAwait(false);

                        premiumToken = JsonConvert.DeserializeObject <PremiumAccessToken>(unencryptedPremiumToken);
                    }
                } catch (NotPremiumUserException) {
                    premiumToken = null;
                }
                return(premiumToken);
            }
예제 #4
0
            async Task<PremiumAccessToken> GetPremiumTokenInternal(string encryptedPremiumToken, string apiKey) {
                var premiumToken = _settings.AccountOptions.UserInfo.Token;
                try {
                    var premiumCached = _firstCompleted && premiumToken.IsPremium() &&
                                        premiumToken.IsValidInNearFuture();
                    if (!premiumCached) {
                        var aes = new Aes();
                        var sha1 = new SHA1Hash();

                        var keyHash = await sha1.GetHashAsync(apiKey).ConfigureAwait(false);
                        var unencryptedPremiumToken =
                            await aes.DecryptAsync(encryptedPremiumToken, keyHash).ConfigureAwait(false);
                        premiumToken = JsonConvert.DeserializeObject<PremiumAccessToken>(unencryptedPremiumToken);
                    }
                } catch (NotPremiumUserException) {
                    premiumToken = null;
                }
                return premiumToken;
            }