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; }
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); }
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); }
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; }