public static string Encrypt(string key) { string timespan = TimeConvert.GetCurrentUTCTimeSpan(); string mixedKey = $"{timespan}&{key}&{_desKey}"; return(DESProvider.Encrypt(mixedKey, _desKey)); }
public static bool KeyIsAvailable(string key) { try { var mixedKey = DESProvider.Decrypt(key, _desKey); var parameters = mixedKey.Split('&'); var keyTime = TimeConvert.TimeSpanToUTCDateTime(parameters[0]); if ((DateTime.UtcNow - keyTime) > _expireTime || parameters[1] != _pcsKey || parameters[2] != _desKey) { return(false); } return(true); } catch { return(false); } }