v0.2.2: updated Lidgren, railgun shells can be bought, autorestart server, netstats, tutorial moloch spawning in a wall fix, misc error checks
This commit is contained in:
45
Lidgren.Network/Encryption/NetEncryption.cs
Normal file
45
Lidgren.Network/Encryption/NetEncryption.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for an encryption algorithm
|
||||
/// </summary>
|
||||
public abstract class NetEncryption
|
||||
{
|
||||
/// <summary>
|
||||
/// NetPeer
|
||||
/// </summary>
|
||||
protected NetPeer m_peer;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public NetEncryption(NetPeer peer)
|
||||
{
|
||||
if (peer == null)
|
||||
throw new NetException("Peer must not be null");
|
||||
m_peer = peer;
|
||||
}
|
||||
|
||||
public void SetKey(string str)
|
||||
{
|
||||
var bytes = System.Text.Encoding.ASCII.GetBytes(str);
|
||||
SetKey(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
public abstract void SetKey(byte[] data, int offset, int count);
|
||||
|
||||
/// <summary>
|
||||
/// Encrypt an outgoing message in place
|
||||
/// </summary>
|
||||
public abstract bool Encrypt(NetOutgoingMessage msg);
|
||||
|
||||
/// <summary>
|
||||
/// Decrypt an incoming message in place
|
||||
/// </summary>
|
||||
public abstract bool Decrypt(NetIncomingMessage msg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user