more progress :D
This commit is contained in:
parent
d49131bc67
commit
c4524fb62e
6 changed files with 210 additions and 51 deletions
|
@ -1,11 +0,0 @@
|
|||
using System.Security.Cryptography;
|
||||
|
||||
namespace lib;
|
||||
|
||||
public static class Crypto {
|
||||
public static RSA GenerateKey() {
|
||||
return RSA.Create(512);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -3,8 +3,31 @@
|
|||
public enum RequestType {
|
||||
Register = 1,
|
||||
ConfirmRegister = 2,
|
||||
GetMessages = 3,
|
||||
GetUserKey = 4,
|
||||
SendMessage = 5,
|
||||
SendAck = 6
|
||||
Login = 3,
|
||||
GetMessages = 4,
|
||||
GetUserKey = 5,
|
||||
SendMessage = 6,
|
||||
}
|
||||
|
||||
public static class Request {
|
||||
public static byte[] CreateRequest(RequestType Type, ref byte counter, byte[] data) {
|
||||
if(data.Length > 13) {
|
||||
throw new Exception("extra data is too long");
|
||||
}
|
||||
|
||||
byte[] msg = new byte[128];
|
||||
msg[0] = 0; // version
|
||||
msg[1] = (byte)Type;
|
||||
msg[2] = counter;
|
||||
if(counter == byte.MaxValue) {
|
||||
counter = 0;
|
||||
}
|
||||
else {
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
// insert data 3..16
|
||||
Array.Copy(data, 0, msg, 3, data.Length);
|
||||
return msg;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue