byte

Convert string to string[] and then convert string[] to byte[]

纵饮孤独 提交于 2019-12-13 18:45:47
问题 Details about the application: Developed under Visual Studio 2019 (Windows 10) Designed on UWP platform with C# & XAML language The application receives information from a remote server. A connection with sockets is used for communication between the two parties. To communicate with the server, the application must send the data in a Byte Array so that it can be read correctly. Currently I use this method to pass my variables in bytes[]: var ID_MESSAGE_ARRAY = BitConverter.GetBytes((int

Webodf display odf from bytes

浪尽此生 提交于 2019-12-13 18:20:01
问题 Is it possible for webodf to read a odf / odt file from its bytes? instead of an url? Currently using: var odfelement = document.getElementById("odf"); var odfcanvas = new odf.OdfCanvas(odfelement); odfcanvas.load("url/to/file.odt"); and would like something like odfcanvas.loadFromBytes(bytes); 回答1: Yes, It is possible to read an odt file from byte Array and then load it in webodf editor. To do so ,you will have to use javascript blob objects to construct a file from a byte array(desired file

Silverlight. Play video from byte array

若如初见. 提交于 2019-12-13 17:15:12
问题 I have Silverlight application that recieves special structure of media: images and videos. Data is recieved as byte[] for each image or video To show images, I use: MemoryStream stream = new MemoryStream(Node.ResourceBin); BitmapImage bmp = new BitmapImage(); bmp.SetSource(stream); ImageContainer.Source = bmp; And it works. To show video I have tried: MemoryStream stream = new MemoryStream(); stream.Write(Node.ResourceBin, 0, Node.ResourceBin.Length); stream.Position = 0; VideoContainer

Converting c# byte to java byte

吃可爱长大的小学妹 提交于 2019-12-13 16:02:54
问题 I'm not realizing what is wrong with my code, take a look: C# code: const int MOVE = 112; MemoryStream m = new MemoryStream(); m.SetLength(4 + 1 + (1 + 1 + 1 + 1)); BinaryWriter bw = new BinaryWriter(m); int id_ = getId(); bw.Write(Converter.GetBigEndian(id_)); sbyte eventMove = MOVE; sbyte rowFromByte = 4; sbyte colFromByte = 2; sbyte rowToByte = 1; sbyte colToByte = 3; bw.Write(eventMove); bw.Write(rowFromByte); bw.Write(colFromByte); bw.Write(rowToByte); bw.Write(colToByte); When I read on

The input stream is not a valid binary format. Serialization issue

扶醉桌前 提交于 2019-12-13 09:02:49
问题 Hello I'm having some problems with this piece of code: This: public void SendRegistrationPacket() { Packet p = new Packet(PacketType.Registration, "server"); p.Gdata.Add(id); clientSocket.Send(p.ToBytes()); } sends p.ToBytes() to this: public Packet(byte[] packetbytes) { BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(packetbytes); Packet p = (Packet)bf.Deserialize(ms); ms.Close(); this.Gdata = p.Gdata; this.packetInt = p.packetInt; this.packetBool = p

Segmentation fault (core dumped) in C byte reader

前提是你 提交于 2019-12-13 09:01:23
问题 I have an assignment for my intro to system operations class that has two distinct parts, the first being a simple program to read an executable, byte by byte, and output the strings entered that are at least 4 characters long. It is a simple modeling of the strings program (command) you can use in UNIX. I'm having a segmentation fault (core dumped) error for three separate sample executables that I feed into it. I understand that this essentially means I'm trying to access some memory

Please how can i return decoded bytes instead of text from a CryptoStream

守給你的承諾、 提交于 2019-12-13 08:53:45
问题 Please how can i return the decoded bytes instead of text in the following snippet: Public Shared Function decryptAsText(key As Byte(), ciphertext As Byte(), iv As Byte()) As String Dim dec As String = Nothing Try Using rj = New Security.Cryptography.RijndaelManaged With {.Key = key, .IV = iv, .Mode = Security.Cryptography.CipherMode.CBC, .Padding = PaddingMode.PKCS7} Using ms = New IO.MemoryStream(ciphertext) Using cs = New Security.Cryptography.CryptoStream(ms, rj.CreateDecryptor(key, iv),

How to send generics over UDP connection C#?

半城伤御伤魂 提交于 2019-12-13 08:36:09
问题 I'm wondering is there a way to send some kind of generics for example List <float> floatValues = new List<float>() need to be sent to udp client. I don't know how to do that, any help will be appreciated! 回答1: You can serialize floatValues using some serialization facility (like XmlSerializer, BinaryFormatter or DataContractSerializer) and than deserialize it back. Or you can create your own "application level protocol" and put to the stream type name and serializer type and use this

NumberFormatException with Integer.parseInt() [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-13 07:46:59
问题 This question already has answers here : What is a NumberFormatException and how can I fix it? [duplicate] (9 answers) Closed 3 years ago . I've a problem with Integer.parseInt(). Specifically my code do this: serverPort variable is an int correctly initialized to 1910 byte[] multicastMessage = (serverAddress+"::"+String.valueOf(serverPort)).getBytes(); byte[] receivedBytes = receivePacket.getData(); receivedString = new String(receivedBytes, "UTF-8"); String[] decodedString = receivedString

Java convert string hex values to byte[], recreating this obj-c functionality

☆樱花仙子☆ 提交于 2019-12-13 07:29:31
问题 I am making an app that communicates with a specific Bluetooth Low Energy device. It requires a specific handshake and this is all working perfectly in Objective-C for iOS , however, I am having trouble recreating this functionality in Java Any thoughts greatly appreciated! WORKING Objective-C code: uint8_t bytes[] = {0x04,0x08,0x0F,0x66,0x99,0x41,0x52,0x43,0x55,0xAA}; NSData *data = [NSData dataWithBytes:bytes length:sizeof(bytes)]; [_btDevice writeValue:data forCharacteristic: