private static async Task RunClient(string ip, int port) { EncryptionLazyWithoutKeyDecorator <byte[]> encrypt = new EncryptionLazyWithoutKeyDecorator <byte[]>(val => { BlowfishEncryptionService encryptionService = new BlowfishEncryptionService(); encryptionService.Initialize(val); return(encryptionService); }, 8); EncryptionLazyWithoutKeyDecorator <byte[]> decrypt = new EncryptionLazyWithoutKeyDecorator <byte[]>(val => { BlowfishDecryptionService decryptionService = new BlowfishDecryptionService(); decryptionService.Initialize(val); return(decryptionService); }, 8); EncryptionKeyInitializer = encrypt; DecryptionKeyInitializer = decrypt; //Configurs and builds the clients without all the //relevant decorators IManagedNetworkClient <PSOBBGamePacketPayloadClient, PSOBBGamePacketPayloadServer> client = new DotNetTcpClientNetworkClient() .AddCryptHandling(encrypt, decrypt) .AddHeaderReading <PSOBBPacketHeader>(new FreecraftCoreGladNetSerializerAdapter(Serializer), 4) .AddNetworkMessageReading(new FreecraftCoreGladNetSerializerAdapter(Serializer)) .For <PSOBBGamePacketPayloadServer, PSOBBGamePacketPayloadClient, IPacketPayload>(new PSOBBPacketHeaderFactory()) .AddReadBufferClearing() .Build() .AsManaged(); MessageContextFactory = new DefaultMessageContextFactory(); await Task.Run(() => RunClientAsync(client, ip, port)); }
public BlowfishEncryptionServiceTests() { _service = new BlowfishEncryptionService(); }