unsafe void IUnsafeElementAccessor <ColorBgra32> .CopyElements(ColorBgra32[] dst, int dstIndex, void *pSrc, int length) { fixed(ColorBgra32 *bgraRef = dst) { BufferUtil.CopyElements((void *)bgraRef, dst.Length, dstIndex, pSrc, length, sizeof(ColorBgra32)); } }
/// <summary> /// Creates a new Aeron source with the specified parameters. /// </summary> /// <param name="aeron">the Aeron connection to use</param> /// <param name="stream">the Aeron stream ID to use</param> /// <param name="channel">the Aeron channel to use</param> /// <param name="bufferSize">the data buffer size to use (in bytes)</param> public Source(Aeron aeron, int stream, string channel, int bufferSize) { _stream = stream; _channel = channel; _buffer = new UnsafeBuffer(BufferUtil.AllocateDirectAligned(bufferSize, BitUtil.CACHE_LINE_LENGTH)); _publication = aeron.AddPublication(_channel, _stream); }
public string getMemberInfoDetail(string USER_ID, string AREA_NO, string D401_21) { string retStr = ""; try { //根据USER_ID获取缓存的新医疗卡号信息 string D401_10 = BufferUtil.getBufferByKey(USER_ID, "D401_10"); //查询成员基本信息 MZBC_Get_Member_Information getMemberInfo = new MZBC_Get_Member_Information(); getMemberInfo.executeSql( new Dictionary <string, string>() { { "AREA_NO", AREA_NO }, { "D401_10", D401_10 }, { "D401_21", D401_21 } } ); Dictionary <string, string> memberBaseInfo = getMemberInfo.getResponseResultWrapperMap(); //成员基本信息 retStr = DataConvert.Dict2Json(memberBaseInfo); retStr = DataConvert.getReturnJson("0", retStr); } catch (Exception ex) { XnhLogger.log(this.GetType().ToString() + " " + ex.StackTrace); retStr = DataConvert.getReturnJson("-1", ex.ToString()); } return(retStr); }
public bool VerifyHashedPassword(byte[] decodedHashedPassword, string providedPassword) { // Read header information var prf = (KeyDerivationPrf)BufferUtil.ReadNetworkByteOrder(decodedHashedPassword, 1); var iterCount = (int)BufferUtil.ReadNetworkByteOrder(decodedHashedPassword, 5); var saltLength = (int)BufferUtil.ReadNetworkByteOrder(decodedHashedPassword, 9); // Read the salt: must be >= 128 bits if (saltLength < 128 / 8) { return(false); } var salt = new byte[saltLength]; Buffer.BlockCopy(decodedHashedPassword, 13, salt, 0, salt.Length); // Read the subkey (the rest of the payload): must be >= 128 bits var subkeyLength = decodedHashedPassword.Length - 13 - salt.Length; if (subkeyLength < 128 / 8) { return(false); } var expectedSubkey = new byte[subkeyLength]; Buffer.BlockCopy(decodedHashedPassword, 13 + salt.Length, expectedSubkey, 0, expectedSubkey.Length); // Hash the incoming password and verify it var actualSubKey = KeyDerivation.Pbkdf2(providedPassword, salt, prf, iterCount, subkeyLength); return(iterCount > 0 && BufferUtil.ByteArraysEqual(actualSubKey, expectedSubkey)); }
public bool VerifyHashedPassword(byte[] decodedHashedPassword, string providedPassword) { var paddingMode = (PaddingMode)BufferUtil.ReadNetworkByteOrder(decodedHashedPassword, 1); var cipherMode = (CipherMode)BufferUtil.ReadNetworkByteOrder(decodedHashedPassword, 5); var salt = new byte[32]; Buffer.BlockCopy(decodedHashedPassword, 9, salt, 0, salt.Length); var iv = new byte[16]; Buffer.BlockCopy(decodedHashedPassword, 9 + salt.Length, iv, 0, iv.Length); var expectedKey = new byte[decodedHashedPassword.Length - salt.Length - iv.Length - 9]; Buffer.BlockCopy(decodedHashedPassword, 9 + salt.Length + iv.Length, expectedKey, 0, expectedKey.Length); var cipher = Aes.Create(); cipher.KeySize = 256; cipher.Padding = paddingMode; cipher.Mode = cipherMode; cipher.Key = salt; cipher.IV = iv; var decryptor = cipher.CreateDecryptor(); var expectedPasswordBytes = decryptor.TransformFinalBlock(expectedKey, 0, expectedKey.Length); var expectedPassword = Encoding.UTF8.GetString(expectedPasswordBytes); return(providedPassword.Equals(expectedPassword)); }
public unsafe void CopyElements(byte[] dst, int dstIndex, void *pSrc, int length) { fixed(byte *numRef = dst) { BufferUtil.CopyElements((void *)numRef, dst.Length, dstIndex, pSrc, length, 1); } }
public unsafe void CopyElements(void *pDst, byte[] src, int srcIndex, int length) { fixed(byte *numRef = src) { BufferUtil.CopyElements(pDst, (void *)numRef, src.Length, srcIndex, length, 1); } }
unsafe void IUnsafeElementAccessor <ColorBgra32> .CopyElements(void *pDst, ColorBgra32[] src, int srcIndex, int length) { fixed(ColorBgra32 *bgraRef = src) { BufferUtil.CopyElements(pDst, (void *)bgraRef, src.Length, srcIndex, length, sizeof(ColorBgra32)); } }
public virtual Map Load(string fileName) { if (fileName == null) { throw new ArgumentNullException("fileName"); } using (FileStream mapStream = File.OpenRead(fileName)) { using (GZipStream gs = new GZipStream(mapStream, CompressionMode.Decompress)) { Map map = LoadHeaderInternal(gs); // Read in the map data map.Blocks = new byte[map.Volume]; BufferUtil.ReadAll(gs, map.Blocks); map.ConvertBlockTypes(Mapping); if (gs.ReadByte() != 0xBD) { return(map); } ReadCustomBlocks(gs, map); return(map); } } }
public unsafe void Write(byte *pBuffer, long count) { Validate.Begin().IsNotNull(((void *)pBuffer), "pBuffer").IsNotNegative(count, "count").Check(); long num = this.position + count; if (num < 0L) { throw new IOException($"stream too long, this.position + count = {this.position} + {count} = {num}"); } if (num > this.length) { bool flag = this.position > this.length; if ((num > this.Capacity) && this.EnsureCapacity(num)) { flag = false; } if (flag) { BufferUtil.ZeroMemory(this.buffer + ((byte *)this.length), num - this.length); } this.length = num; } byte *numPtr = this.buffer + ((byte *)this.position); Buffer.MemoryCopy((void *)pBuffer, (void *)numPtr, this.bufferSize, count); this.position += count; }
private void RunLoop(Subscription sub, Publication pub) { var buffer = new UnsafeBuffer(BufferUtil.AllocateDirectAligned(2048, 16)); var random = new Random(); while (true) { if (pub.IsConnected) { if (SendMessage(pub, buffer, "HELLO " + this.local_address.Port)) { break; } } } var assembler = new FragmentAssembler(OnParseMessage); while (true) { if (pub.IsConnected) { SendMessage(pub, buffer, random.Next(0, int.MaxValue).ToString()); } if (sub.IsConnected) { sub.Poll(assembler, 10); } Thread.Sleep(1000); } }
public Map Load(string fileName) { if (fileName == null) { throw new ArgumentNullException("fileName"); } using (FileStream fs = File.OpenRead(fileName)) { using (GZipStream gs = new GZipStream(fs, CompressionMode.Decompress)) { int formatVersion; Map map = LoadHeaderInternal(gs, out formatVersion); map.Blocks = new byte[map.Volume]; if (formatVersion != 1050) { BufferUtil.ReadAll(gs, map.Blocks); } else { byte[] buffer = new byte[4]; for (int i = 0; i < map.Volume; i++) { gs.Read(buffer, 0, 4); map.Blocks[i] = buffer[0]; } } map.ConvertBlockTypes(Mapping); return(map); } } }
public byte[] HashPassword(string password, ISecureRandomGenerator secureRandomGenerator) { var passwordBytes = Encoding.UTF8.GetBytes(password); var salt = secureRandomGenerator.GenerateBytes(32); var iv = secureRandomGenerator.GenerateBytes(16); var cipher = Aes.Create(); cipher.KeySize = 256; cipher.Padding = PaddingMode.PKCS7; cipher.Mode = CipherMode.CBC; cipher.Key = salt; cipher.IV = iv; var encryptor = cipher.CreateEncryptor(); var subKey = encryptor.TransformFinalBlock(passwordBytes, 0, passwordBytes.Length); var outputBytes = new byte[9 + salt.Length + iv.Length + subKey.Length]; outputBytes[0] = FormatMarkers.Aes256; BufferUtil.WriteNetworkByteOrder(outputBytes, 1, (uint)cipher.Padding); BufferUtil.WriteNetworkByteOrder(outputBytes, 5, (uint)cipher.Mode); BufferUtil.BlockFill(salt, outputBytes, 9); BufferUtil.BlockFill(iv, outputBytes, 9 + salt.Length); BufferUtil.BlockFill(subKey, outputBytes, 9 + salt.Length + iv.Length); return(outputBytes); }
public void Run() { var publication = Publication; using (var byteBuffer = BufferUtil.AllocateDirectAligned(publication.MaxMessageLength, BitUtil.CACHE_LINE_LENGTH)) using (var buffer = new UnsafeBuffer(byteBuffer)) { long backPressureCount = 0; long totalMessageCount = 0; while (Running) { for (var i = 0; i < BurstLength; i++) { while (publication.Offer(buffer, 0, MessageLength) <= 0) { ++backPressureCount; if (!Running) { break; } } ++totalMessageCount; } } var backPressureRatio = backPressureCount / (double)totalMessageCount; Console.WriteLine($"Publisher back pressure ratio: {backPressureRatio}"); } }
public ReportCollection() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvCollection, true); this.LoadData(""); }
public MasterVendor() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvVendor, true); this.LoadData(""); }
public FaView() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvFa, true); this.LoadData(""); }
public DisposalProcessing() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvDisposal, true); this.LoadData(); }
public EducationAnswers() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvQuestion, true); this.LoadData(); }
public MasterOem() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvOem, true); this.LoadData(""); }
public DisposalView() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvDisposal, true); Application.Idle += new EventHandler(Application_Idle); }
public ServerClient(int session, Image in_image, Aeron in_aeron) { this.session = session; this.image = in_image ?? throw new ArgumentNullException(nameof(in_image)); this.aeron = in_aeron ?? throw new ArgumentNullException(nameof(in_aeron)); this.state = State.INITIAL; this.buffer = new UnsafeBuffer(BufferUtil.AllocateDirectAligned(2048, 16)); }
public InstockView() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvInstock, true); Application.Idle += new EventHandler(Application_Idle); }
public ReportModify() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvModifyRecord, true); this.LoadData(""); }
public MasterMouldCode() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvMouldCode, true); this.LoadData(""); }
public PoView() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvIssuePO, true); this.LoadData(""); }
public DisposalHistory() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvHistory, true); this.LoadData(""); }
public EducationReport() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvRecord, true); this.LoadData(""); }
/// <summary> /// Emit a DMesh3 as a CompressedDMeshStruct /// </summary> public static void EmitDMeshCompressed_Minimal(this SceneSerializer s, DMesh3 m, IOutputStream o) { SceneSerializer.EmitOptions opt = s.CurrentOptions; // compressed version - uuencoded byte buffers // - storing doubles uses roughly same mem as string, but string is only 8 digits precision // - storing floats saves roughly 50% // - storing triangles is worse until vertex count > 9999 // - could store as byte or short in those cases... // - edges and edge ref counts are stored, then use mesh.RebuildFromEdgeRefcounts() to rebuild 3D mesh (same as gSerialization) o.BeginStruct(IOStrings.CompressedDMeshStruct); o.AddAttribute(IOStrings.AMeshStorageMode, (int)IOStrings.MeshStorageMode.Minimal); // need compact mesh to do this if (m.IsCompactV == false) { m = new DMesh3(m, true); } o.AddAttribute(IOStrings.AMeshVertices3Compressed, BufferUtil.CompressZLib(m.VerticesBuffer.GetBytes(), opt.FastCompression)); if (opt.StoreMeshVertexNormals && m.HasVertexNormals) { o.AddAttribute(IOStrings.AMeshNormals3Compressed, BufferUtil.CompressZLib(m.NormalsBuffer.GetBytes(), opt.FastCompression)); } if (opt.StoreMeshVertexColors && m.HasVertexColors) { o.AddAttribute(IOStrings.AMeshColors3Compressed, BufferUtil.CompressZLib(m.ColorsBuffer.GetBytes(), opt.FastCompression)); } if (opt.StoreMeshVertexUVs && m.HasVertexUVs) { o.AddAttribute(IOStrings.AMeshUVs2Compressed, BufferUtil.CompressZLib(m.UVBuffer.GetBytes(), opt.FastCompression)); } int[] triangles = new int[3 * m.TriangleCount]; int k = 0; foreach (int tid in m.TriangleIndices()) { Index3i t = m.GetTriangle(tid); triangles[k++] = t.a; triangles[k++] = t.b; triangles[k++] = t.c; } o.AddAttribute(IOStrings.AMeshTrianglesCompressed, BufferUtil.CompressZLib(BufferUtil.ToBytes(triangles), opt.FastCompression)); if (opt.StoreMeshFaceGroups && m.HasTriangleGroups) { int[] groups = new int[m.TriangleCount]; k = 0; foreach (int tid in m.TriangleIndices()) { groups[k++] = m.GetTriangleGroup(tid); } o.AddAttribute(IOStrings.AMeshTriangleGroupsCompressed, BufferUtil.CompressZLib(BufferUtil.ToBytes(groups), opt.FastCompression)); } o.EndStruct(); }
public TransferView() { InitializeComponent(); BufferUtil.DoubleBuffered(dgvPreview, true); BufferUtil.DoubleBuffered(dgvSearch, true); Application.Idle += new EventHandler(Application_Idle); }