Files
shadowsocks-windows/shadowsocks-csharp/Encryption/EncryptorBase.cs
T
Syrone Wong 8637277c27 Cleanup
- drop unused using directive
- add a comment

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-08-17 15:58:00 +08:00

37 lines
1.0 KiB
C#

using System.Text;
namespace Shadowsocks.Encryption
{
public abstract class EncryptorBase
: IEncryptor
{
public const int MAX_INPUT_SIZE = 32768;
protected EncryptorBase(string method, string password, bool onetimeauth, bool isudp)
{
Method = method;
Password = password;
OnetimeAuth = onetimeauth;
IsUDP = isudp;
}
protected string Method;
protected string Password;
protected bool OnetimeAuth;
protected bool IsUDP;
protected byte[] GetPasswordHash()
{
byte[] inputBytes = Encoding.UTF8.GetBytes(Password);
byte[] hash = MbedTLS.MD5(inputBytes);
return hash;
}
public abstract void Encrypt(byte[] buf, int length, byte[] outbuf, out int outlength);
public abstract void Decrypt(byte[] buf, int length, byte[] outbuf, out int outlength);
public abstract void Dispose();
}
}