/// <summary> /// 将获取到的消息重新发送到队列中, 根据配置, 可以转发到其他MQ队列, 也可以执行重试计数 /// </summary> protected void ReSendMQ() { if (CurrentMessage == null) { return; } if (string.IsNullOrEmpty(MyConfig.RetryAddress) == false) { //失败转发 try { MessageQueueTools.SendMessage(MyConfig.RetryAddress, CurrentMessage); } catch (Exception ex) { ThisLogger.Error(ex, MyConfig.RetryAddress, CurrentMessage.Body); } } else if (MyConfig.RetryCount > 0) { //失败重试 int TryTimes = 0; try { if (string.IsNullOrEmpty(CurrentMessage.Label) || int.TryParse(CurrentMessage.Label, out TryTimes) == false) { TryTimes = 0; } if (TryTimes < MyConfig.RetryCount) { TryTimes = TryTimes + 1; CurrentMessage.Label = Convert.ToString(TryTimes); MessageQueueTools.SendMessage(MyConfig.Address, CurrentMessage); } else { ThisLogger.Warn(new LogInfo("{0}超过重试计数({1})", CurrentMessage.Body, TryTimes)); } } catch (Exception ex) { ThisLogger.Error(ex, MyConfig.Address, CurrentMessage.Label); } } }
public virtual BitString GCTR(BitString icb, BitString x, BitString key) { // ICB must be 128 bits long // ThisLogger.Debug("GCTR"); if (icb.BitLength != 128) { ThisLogger.Warn($"icbLen:{icb.BitLength}"); return(null); } // Step 1: If X is the empty string, then return the empty string as Y if (x.BitLength == 0) { return(new BitString(0)); } var ecb = _modeFactory.GetStandardCipher( _engineFactory.GetSymmetricCipherPrimitive(BlockCipherEngines.Aes), BlockCipherModesOfOperation.Ecb ); // Step 2: Let n = ceil[ len(X)/128 ] int n = x.BitLength.CeilingDivide(128); // Step 3: Let X1,X2,...,Xn-1,Xn denote the unique sequence of bit // strings such that X = X1 || X2 || ... || Xn-1 || Xn* // X1, X2,...,Xn-1 are complete blocks // Xn* is either a complete block or a partial block // Step 4: Let CB1 = ICB // Step 5: For i = 2 to n, let CBi = inc32(CBi-1) // Step 6: For i = 1 to n-1, let Yi = Xi xor CIPH_K(CBi) BitString cbi = icb; BitString Y = new BitString(0); int sx = x.BitLength - 128; for (int i = 1; i <= (n - 1); ++i, sx -= 128) { if (i > 1) { cbi = inc_s(32, cbi); } BitString xi = x.Substring(sx, 128); var cbiParam = new ModeBlockCipherParameters( BlockCipherDirections.Encrypt, key, cbi ); var h = ecb.ProcessPayload(cbiParam); BitString yi = BitString.XOR(xi, h.Result); Y = Y.ConcatenateBits(yi); // This is part of Step 8 } // Step 7: Let Yn* = Xn* xor MSB_len(Xn*) (CIPH_K(CBn)) // i == n case: if (n > 1) { cbi = inc_s(32, cbi); } var xn = x.Substring(0, 128 + sx); var cbiParam1 = new ModeBlockCipherParameters( BlockCipherDirections.Encrypt, key, cbi ); var h1 = ecb.ProcessPayload(cbiParam1); var yn = xn.XOR(h1.Result.GetMostSignificantBits(xn.BitLength)); Y = Y.ConcatenateBits(yn); // This is part of Step 8 // Step 8: Let Y = Y1 || ... || Yn* // Step 9: Return Y return(Y); }