Files
shadowsocks-windows/shadowsocks-csharp/Encrypt/EncryptorBase.cs
T
2014-11-02 20:27:18 +08:00

32 lines
873 B
C#

using System.Security.Cryptography;
using System.Text;
namespace shadowsocks_csharp.Encrypt
{
public abstract class EncryptorBase
: IEncryptor
{
protected EncryptorBase(string method, string password)
{
Method = method;
Password = password;
}
protected string Method;
protected string Password;
protected byte[] GetPasswordHash()
{
byte[] inputBytes = Encoding.UTF8.GetBytes(Password);
byte[] hash = MD5.Create().ComputeHash(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();
}
}