public EncryptorAsyncResult(PeerId id, AsyncCallback callback, object state) : base(callback, state) { Id = id; Decryptor = new PlainTextEncryption(); Encryptor = new PlainTextEncryption(); }
public StudentsController(IStudentsServices studentServices, IEmail email, IEncryption encryption, IHoursServices hoursServices) { _studentsServices = studentServices; _email = email; _encryption = encryption; _hoursServices = hoursServices; }
public CollegeEducationController(NEPService.CollegeService.ICollegeService collegeService, IClientService clientService, NEPService.EducationService.IEducationService educationService, IEncryption encryptionService) { _collegeService = collegeService; _educationService = educationService; _encryptionService = encryptionService; _clientService = clientService; }
public override void SaveAs(string path, string header, IEncryption encrypt) { using (Stream stream1 = File.Open(path, FileMode.Create, FileAccess.Write, this.mShareMode)) { this.SaveAs(stream1, header, encrypt); } }
protected internal MainWindowViewModel(IEncryption encryption) : base(true) { _encryption = encryption ?? throw new ArgumentNullException(nameof(encryption)); EncryptClick = new DefaultCommand { Text = "Encrypt", Command = new RelayCommand(rc => BtnEncryptClick()) }; DecryptClick = new DefaultCommand { Text = "Decrypt", Command = new RelayCommand(rc => BtnDecryptClick()) }; CompareClick = new DefaultCommand { Text = "Compare", Command = new RelayCommand(rc => BtnCompareClick()) }; AboutWindowClick = new DefaultCommand { Text = "About", Command = new RelayCommand(rc => BtnAboutWindowClick()) }; LostFocus = new DefaultCommand { Command = new RelayCommand(rc => ExecuteCustomColorOnLostFocus()) }; }
/// <summary> /// Converts the user entered data into a User object. /// </summary> /// <param name="encryption">Business class used to encrypt /// the password entered by the user.</param> /// <returns>User object made up of this data.</returns> public virtual User ToUser(IEncryption encryption) { var user = new User(); user.Username = Username; user.SetPassword(encryption.Encrypt(Password)); return user; }
public AbstractReader(IEncryption encryption = null, ISecurityRole securityRole = null, string userName = null, string roleName = null) { ReaderEncryption = encryption; SecurityRole = securityRole; UserName = userName; RoleName = roleName; }
private void HandleAuthTokenKey(IDBService dbProxy, IEncryption encryption) { if (AuthTokenHelper.IsAuthTokenExits(_httpProxy)) { var userId = AuthTokenHelper.GetUserId(_httpProxy, dbProxy, encryption); var userTempData = _httpProxy.GetTempValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY); if (userTempData == null) { ISessionProvider session = new SessionProvider(_httpProxy, dbProxy, _logger); var userData = session.GetValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY); if (userData != null && userData.user_id != userId) { throw new Exception("Session user conflict with authtoken"); } if (userData == null) { userData = dbProxy.FirstOrDefault <UserModel>(CommonConst.Collection.USERS, CommonConst.CommonField.USER_ID, userId); if (userData == null) { throw new Exception("User not found for authtoken"); } } _httpProxy.SetTempValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY, userData); } } }
public UserController(IUser userBL, IUserRepository userRepository, IEncryption encryptionService, IARCommonServices arCommonService) { _userRepository = userRepository; _userBL = userBL; _encryptionService = encryptionService; _arCommonService = arCommonService; }
public ExtensionSettings(IOrganizationService OrgService, IXrmCache cache, IEncryption encryption, IExtensionSettingsConfig config) { try { if (OrgService == null) { throw new ArgumentNullException("OrgService is required."); } if (cache == null) { throw new ArgumentNullException("cache is required."); } if (config == null) { throw new ArgumentNullException("config is required."); } if (encryption == null) { throw new ArgumentNullException("encryption is required."); } this.config = config; this.orgService = OrgService; this.cache = cache; this.encryption = encryption; encryptionKey = !string.IsNullOrEmpty(config.EncryptionKey) ? config.EncryptionKey : DEFAULT_ENCRYPTION_KEY; } catch (Exception ex) { throw new Exception(string.Format("Error constructing ExtensionSettings: {0}", ex.Message), ex); } }
/// <summary> /// Constructor. Uses DI /// </summary> /// <param name="userService">DI service to get user information.</param> /// <param name="config">DI config information.</param> public LoginHandler(IAPIModelService <UsersDTO> userService, IConfiguration config, IEncryption <string, string> encryption, IHttpContextAccessor contextAccessor) { _userService = userService; _config = config; this.encryption = encryption; this.context = contextAccessor.HttpContext; }
public RequestBuilder(IEncryption encryption, ISettings settings) { this.encryption = encryption; this.settings = settings; Date = DateTime.Now; }
public TFSOnlineProvider( IEncryption encryption , IRepository <Project> projectRepository) { this.encryption = encryption; this.projectRepository = projectRepository; }
public void SetUp() { e = new Encryption(); encryption = MockRepository.GenerateMock<IEncryption>(); log = MockRepository.GenerateMock<ILog>(); encryption.Expect(x => x.Decrypt(e.Encrypt(ConnectionString))).Return(ConnectionString); }
public EncryptorAsyncResult(PeerId id, AsyncCallback callback, object state) : base(callback, state) { Id = id; Decryptor = new PlainTextEncryption(); Encryptor = new PlainTextEncryption(); }
async void ReceiveMessagesAsync(IConnection connection, IEncryption decryptor, RateLimiterGroup downloadLimiter, ConnectionMonitor monitor, TorrentManager torrentManager, PeerId id) { try { while (true) { var message = await PeerIO.ReceiveMessageAsync(connection, decryptor, downloadLimiter, monitor, torrentManager); if (id.Disposed) { if (message is PieceMessage msg) { ClientEngine.BufferManager.FreeBuffer(msg.Data); } } else { id.LastMessageReceived.Restart(); if (PeerMessageTransferred != null) { RaisePeerMessageTransferred(new PeerMessageEventArgs(id.TorrentManager, message, Direction.Incoming, id)); } message.Handle(id); } } } catch { CleanupSocket(id, "Could not receive a message"); } }
public static ParamContainer CreateParamContainer(ILogger loggerController, IActionExecuter actionExecuter) { ILogReader logReader = Logger.GetLogReader(); IAppSettingService appSettingService = AppSettingService.Instance; ParamContainer paramContainer = new ParamContainer(); IDBService dbService = ApplicationConfig.DependencyResolver.GetInstance <IDBService>(); IPingService pingService = ApplicationConfig.DependencyResolver.GetInstance <IPingService>(); IViewEngine viewEngine = ApplicationConfig.DependencyResolver.GetInstance <IViewEngine>(); IEncryption encryption = ApplicationConfig.DependencyResolver.GetInstance <IEncryption>(); IKeyValueStorage keyValueStorage = ApplicationConfig.DependencyResolver.GetInstance <IKeyValueStorage>(); ISMSService smsService = new SMSService(loggerController, dbService, actionExecuter, viewEngine, paramContainer); IEmailService emailService = new EmailService(loggerController, dbService, actionExecuter, viewEngine, paramContainer); IOTPService otpService = new OTPService(loggerController, dbService, smsService, emailService, appSettingService); paramContainer.AddKey(CommonConst.CommonValue.PARAM_DBPROXY, () => { return(dbService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_LOGGER, () => { return(loggerController); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_ACTIONEXECUTER, () => { return(actionExecuter); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_PING_SERVICE, () => { return(pingService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_PING_SERVICE, () => { return(pingService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_APP_SETTING, () => { return(appSettingService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_VIEW_ENGINE, () => { return(viewEngine); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_OTP_SERVICE, () => { return(otpService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_SMS_SERVICE, () => { return(smsService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_EMAIL_SERVICE, () => { return(emailService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_ENCRYPTION_SERVICE, () => { return(encryption); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_KEY_VALUE_STORAGE, () => { return(keyValueStorage); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_HTTP_CLIENT, () => { return(new HttpRestClient()); }); return(paramContainer); }
public void Setup() { _context = MockRepository.GenerateStub <ISeContext>(); _context.LookupItem = new TestDbSet <LookupItem> { new LookupItem { LookupTypeId = Consts.LookupTypeId.BadPassword, Description = "Password1" }, new LookupItem { LookupTypeId = Consts.LookupTypeId.BadPassword, Description = "LetMeIn123" }, new LookupItem { LookupTypeId = Consts.LookupTypeId.SecurityQuestion, Id = 142 } }; _context.User = new TestDbSet <User>(); _context.UserLog = new TestDbSet <UserLog>(); _configuration = MockRepository.GenerateStub <IAppConfiguration>(); _encryption = MockRepository.GenerateMock <IEncryption>(); _services = MockRepository.GenerateMock <IServices>(); _userStore = MockRepository.GenerateMock <IAppUserStore <User> >(); _bannedWords = new List <string> { "First Name", "SurName", "My Town", "My PostCode" }; _pwnedPasswordValidator = MockRepository.GenerateMock <IPwnedPasswordValidator>(); _sut = new AppUserManager(_configuration, _context, _encryption, _pwnedPasswordValidator, _services, _userStore); }
private void SaveIndirect(XRefEntry e, PDFIndirect i) { if (i.PDFType == PDFObjectType.tPDFStream) { foreach (IStreamEncodingRule rule1 in base.StreamEncodingRules) { if (rule1.Handle(((PDFStream)i.Direct))) { goto Label_0051; } } } Label_0051: e.offset = this.mWriter.Position; this.mWriter.WriteSp(i.Id); this.mWriter.WriteSp(i.Generation); this.mWriter.WriteRaw("obj"); this.mWriter.WriteEOL(); IEncryption encryption1 = this.mWriter.Encryption; if ((this.mTrailer["Encrypt"] != null) && (i.Id == this.mTrailer["Encrypt"].Indirect.Id)) { this.mWriter.Encryption = null; } this.mWriter.WriteLn(i.Direct); this.mWriter.Encryption = encryption1; this.mWriter.WriteRaw("endobj"); this.mWriter.WriteEOL(); i.Dirty = false; }
public FileSystemRepository(ILogger logger, ISettings settings, IEncryption encryption, Util.Util util) { _logger = logger; _settings = settings; _encryption = encryption; _util = util; }
public ApiController(IAccountService accountService, IClientManager clientManager, IEncryption encryption) { _accountService = accountService; _clientManager = clientManager; _encryption = encryption; }
/// <summary> /// /// </summary> /// <param name="storageProvider"></param> /// <param name="serializer"></param> internal ConfigProvider(IConfigStorageProvider storageProvider, ISerialization serializer, IEncryption encryption, string key) { this.storageProvider = storageProvider; this.encryption = encryption; this.key = key; this.serializer = serializer; }
/// <summary> /// Returns the implementation IEncryption custom or default. /// </summary> /// <returns></returns> internal static IEncryption GetEncryption() { var nameType = ConfigurationManager.AppSettings["CaptchaIEncryption"]; if (!string.IsNullOrEmpty(nameType)) { if (nameType == _nameEncryption) { return(_encryption); } var type = GetType("IEncryption", nameType); if (type != null) { var result = (IEncryption)type.Assembly.CreateInstance(type.FullName, true); _encryption = result; _nameEncryption = nameType; return(_encryption); } } if (DefaultName == _nameEncryption) { return(_encryption); } _nameEncryption = DefaultName; _encryption = new Encryption(); return(_encryption); }
/// <summary> /// æž„é€ å‡½æ•° /// </summary> /// <param name="encryptType">åŠ å¯†ç±»åž‹</param> /// <param name="keys">秘钥</param> public EncryptUtils(string encryptType, string keys) { string typeStr = encryptType.ToUpper(); switch (typeStr) { case DES3: m_IEncryption = new DES3(keys); break; case MD5: m_IEncryption = new MD5Encrypt(); break; case DES: m_IEncryption = new DESEncryption(keys); break; case Base64: m_IEncryption = new Base64(); break; default: return; throw new Exception("not support the type:" + encryptType); } }
public void ExecuteRetrieveFile(object args) { try { var deHideOption = this.GetDeHideOptionFromView((Window)args); if (deHideOption == null) { return; } var ciphertext = HideLSB.DeHide(this._hiddenImageBitmapCache); IEncryption encryptor = EncryptionFactory.CreateEncryption(deHideOption.EncryptionAlg); var plaintext = encryptor.Decrypt(ciphertext, this.StrPassword2UintArr(deHideOption.Password)); var deZipdata = Zip.Decompress(plaintext); if (File.Exists(deHideOption.FilePath)) { File.Delete(deHideOption.FilePath); } FileTransform.ByteArray2File(deHideOption.FilePath, deZipdata); this.ShowMessageBoxResource("RetrieveDone", "Hint", MessageBoxButton.OK, MessageBoxImage.Information); } catch (PasswordWrongException) { this.ShowMessageBoxResource("PasswordWrong", "Error"); } catch (Exception) { this.ShowMessageBoxResource("PasswordWrong", "Error"); } }
public CollegeController(NEPService.CollegeService.ICollegeService collegeService, IStorage storageService, NEPService.EducationService.IEducationService educationService, IEncryption encryptionService) { _CollegeService = collegeService; _storageService = storageService; _educationService = educationService; _encryptionService = encryptionService; }
public CommonController(ICommonService commonService, IStorage storageService, IClientService clientService, IEncryption encryptionService) { _commonService = commonService; _storageService = storageService; _clientService = clientService; _encryptionService = encryptionService; }
private RequestBuilder Create() { encryption = For <IEncryption>(); settings = For <ISettings>(); return(new RequestBuilder(encryption, settings)); }
public LoginController(NEPService.ClientService.IClientService clientService, IEncryption encryptionService, IEMail mailService, NEPService.UserService.IUserService userService) { _clientService = clientService; _encryptionService = encryptionService; _mailService = mailService; _userService = userService; }
public bool encryptFile(string UserDirectory, IEncryption encryption, ref int progress) { bufferSize = encryption.getKeySize() / 8; buffer = new byte[bufferSize]; progress = 0; readed = 0; try { using (FileStream SourceReader = File.OpenRead(UserDirectory)) { using (FileStream DestinationWriter = File.OpenWrite(UserDirectory + Consts.ENCRYPT_FILE_NAME)) { while (SourceReader.Read(buffer, 0, bufferSize - 1) != 0) { // Count progress person readed += bufferSize - 1; progress = (int)(100.0 * readed / SourceReader.Length); // Main encrypt file encryption.encrypt(ref buffer); DestinationWriter.Write(buffer, 0, bufferSize); System.Array.Clear(buffer, 0, bufferSize); } } } //System.IO.File.Delete(UserDirectory); GC.Collect(); return(true); } catch (IOException e) { Debug.showLog("func encryptFile", e.Message); return(false); } }
public FileKeyValueFileStorage(IEncryption encryption, IAppSettingService appSettingService, ILogger logger) { _logger = logger; _encryption = encryption; _appSettingService = appSettingService; _storageBasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ZNxtApp", appSettingService.GetAppSettingData("DataBaseName")); }
/// <summary> /// Sets CryptoSelect and initializes the stream encryptor and decryptor based on the selected method. /// </summary> /// <param name="remoteCryptoBytes">The cryptographic methods supported/wanted by the remote client in CryptoProvide format. The highest order one available will be selected</param> /// <param name="replace">True if the existing Encryptor/Decryptor object should be replaced with a new instance</param> protected virtual int SelectCrypto(byte[] remoteCryptoBytes, bool replace) { CryptoSelect = new byte[remoteCryptoBytes.Length]; // '2' corresponds to RC4Full if ((remoteCryptoBytes[3] & 2) == 2 && allowedEncryption.HasFlag(EncryptionTypes.RC4Full)) { CryptoSelect[3] |= 2; if (replace) { Encryptor = encryptor; Decryptor = decryptor; } return(2); } // '1' corresponds to RC4Header if ((remoteCryptoBytes[3] & 1) == 1 && allowedEncryption.HasFlag(EncryptionTypes.RC4Header)) { CryptoSelect[3] |= 1; if (replace) { Encryptor = new RC4Header(); Decryptor = new RC4Header(); } return(1); } throw new EncryptionException("No valid encryption method detected"); }
public static void EnqueueReceiveHandshake(IConnection connection, IEncryption decryptor, AsyncMessageReceivedCallback callback, object state) { var buffer = ClientEngine.BufferManager.GetBuffer(HandshakeMessage.HandshakeLength); var data = receiveCache.Dequeue().Initialise(connection, decryptor, null, null, null, buffer, callback, state); NetworkIO.EnqueueReceive(connection, buffer, 0, HandshakeMessage.HandshakeLength, null, null, null, HandshakeReceivedCallback, data); }
public static async Task SendMessageAsync(IConnection connection, IEncryption encryptor, PeerMessage message, IRateLimiter rateLimiter, ConnectionMonitor peerMonitor, ConnectionMonitor managerMonitor) { int count = message.ByteLength; var buffer = ClientEngine.BufferManager.GetBuffer(count); try { var pieceMessage = message as PieceMessage; message.Encode(buffer, 0); encryptor.Encrypt(buffer, 0, count); // Assume protocol first, then swap it to data once we successfully send the data bytes. await NetworkIO.SendAsync(connection, buffer, 0, count, pieceMessage == null?null : rateLimiter, peerMonitor?.DataUp, managerMonitor?.DataUp).ConfigureAwait(false); if (pieceMessage != null) { peerMonitor?.ProtocolUp.AddDelta(-pieceMessage.RequestLength); managerMonitor?.ProtocolUp.AddDelta(-pieceMessage.RequestLength); peerMonitor?.DataUp.AddDelta(pieceMessage.RequestLength); managerMonitor?.DataUp.AddDelta(pieceMessage.RequestLength); } } finally { ClientEngine.BufferManager.FreeBuffer(ref buffer); } }
public void SetUp() { encryption = new Encryption(); log = MockRepository.GenerateMock<ILog>(); assemblyResolver = MockRepository.GenerateMock<IAssemblyResolver>(); this.dataClientFactory = new DataClientFactory(log, assemblyResolver, encryption); }
internal async void ReceiveMessagesAsync(IConnection connection, IEncryption decryptor, RateLimiterGroup downloadLimiter, ConnectionMonitor monitor, TorrentManager torrentManager, PeerId id) { await MainLoop.SwitchToThreadpool(); ByteBufferPool.Releaser releaser = default; try { while (true) { if (id.AmRequestingPiecesCount == 0 && releaser.Buffer != null) { releaser.Dispose(); releaser = NetworkIO.BufferPool.Rent(1, out ByteBuffer _); } else if (id.AmRequestingPiecesCount > 0 && releaser.Buffer == null) { releaser.Dispose(); releaser = NetworkIO.BufferPool.Rent(Piece.BlockSize, out ByteBuffer _); } PeerMessage message = await PeerIO.ReceiveMessageAsync(connection, decryptor, downloadLimiter, monitor, torrentManager.Monitor, torrentManager, releaser.Buffer).ConfigureAwait(false); HandleReceivedMessage(id, torrentManager, message); } } catch { releaser.Dispose(); await ClientEngine.MainLoop; CleanupSocket(torrentManager, id); } }
public static void EnqueueReceiveMessage(IConnection connection, IEncryption decryptor, IRateLimiter rateLimiter, ConnectionMonitor monitor, TorrentManager manager, AsyncMessageReceivedCallback callback, object state) { // FIXME: Hardcoded number int count = 4; var buffer = ClientEngine.BufferManager.GetBuffer (count); var data = receiveCache.Dequeue ().Initialise (connection, decryptor, rateLimiter, monitor, manager, buffer, callback, state); NetworkIO.EnqueueReceive (connection, buffer, 0, count, rateLimiter, monitor, data.ManagerMonitor, MessageLengthReceivedCallback, data); }
/// <summary> /// Converts the user entered data into a User object. /// </summary> /// <param name="encryption">Business class used to encrypt /// the password entered by the user.</param> /// <returns>User object made up of this data.</returns> public virtual User ToUser(IEncryption encryption) { var user = new User(); user.Username = Username; user.MakeAdmin(); user.Password = encryption.Encrypt(Password); return user; }
protected PluginBase(ILog log, Job job, IEncryption encryption) { this.encryption = encryption; this.Log = log; this.SetOrCreateLogObjectIfNull(); this.Name = job.Name; this.ClientName = job.ClientName; this.Type = job.Type; }
public static void EnqueueReceiveHandshake(IConnection connection, IEncryption decryptor, AsyncMessageReceivedCallback callback, object state) { var buffer = ClientEngine.BufferManager.GetBuffer(HandshakeMessage.HandshakeLength); var data = ReceiveCache.Dequeue() .Initialise(connection, decryptor, null, null, null, buffer, callback, state); NetworkIO.EnqueueReceive(connection, buffer, 0, HandshakeMessage.HandshakeLength, null, null, null, HandshakeReceivedCallback, data); }
public static void EnqueueSendMessage (IConnection connection, IEncryption encryptor, PeerMessage message, IRateLimiter rateLimiter, ConnectionMonitor peerMonitor, ConnectionMonitor managerMonitor, AsyncIOCallback callback, object state) { int count = message.ByteLength; var buffer = ClientEngine.BufferManager.GetBuffer (count); message.Encode (buffer, 0); encryptor.Encrypt (buffer, 0, count); var data = sendCache.Dequeue ().Initialise (buffer, callback, state); NetworkIO.EnqueueSend (connection, buffer, 0, count, rateLimiter, peerMonitor, managerMonitor, EndSendCallback, data); }
public EncryptedDiskService(ConnectionString conn, Logger log) : base(conn, log) { // initialize AES with passoword var password = conn.GetValue<string>("password", null); // hash password to store in header to check if password is correct _crypto = LitePlatform.Platform.GetEncryption(password); _password = _crypto.HashSHA1(password); }
public void getEncrytionType() { if (rb_ROT13.Checked == true) { encryptionType = new ROT13(); } else if (rb_StringReverse.Checked == true) { encryptionType = new StringReverse(); } }
public void SetUp() { var e = new Encryption(); param = new OracleClient { Name = "TestName", ClientName = "TestClientName", ConnectionString = "", Path = "path" }; param.ConnectionString = e.Encrypt(Cs); log = MockRepository.GenerateMock<ILog>(); encryption = MockRepository.GenerateMock<IEncryption>(); encryption.Expect(x => x.Decrypt(e.Encrypt(Cs))).Return(Cs); //encryption.Expect(x => x.Encrypt("abc")).Return(ConnectionString); }
public ReceiveMessageState Initialise (IConnection connection, IEncryption decryptor, IRateLimiter limiter, ConnectionMonitor peerMonitor, TorrentManager manager, byte[] buffer, AsyncMessageReceivedCallback callback, object state) { Connection = connection; Decryptor = decryptor; Manager = manager; Buffer = buffer; PeerMonitor = peerMonitor; RateLimiter = limiter; ManagerMonitor = manager == null ? null : manager.Monitor; Callback = callback; State = state; return this; }
public DefaultAccountService(ICacheManager cacheManager, IRepository<Account> repAccount, IEnumerable<IAccountProvider> accountProviders, IEncryption encryption, IRepository<AccountClient> repAccountClient) { _accountCache = cacheManager.Get<string, IEnumerable<Account>>("AllAccount"); _repAccount = repAccount; _accountProviders = accountProviders; _encryption = encryption; _repAccountClient = repAccountClient; Logger = NullLogger.Instance; }
public void InitiateTransfer(CustomConnection connection) { var id = new PeerId(new Peer("", connection.Uri), rig.Manager); id.Connection = connection; byte[] data; EncryptorFactory.EndCheckEncryption( EncryptorFactory.BeginCheckEncryption(id, 68, null, null, new[] {id.TorrentManager.InfoHash}), out data); decryptor = id.Decryptor; encryptor = id.Encryptor; TestHandshake(data, connection); }
public void InitializeTest() { _container = new GwnClassBase() .GetContainer() // Ensure we're using poor mans encryption (later when // better encryption is available we'll plug it in but // won't want to break unit test). .RegisterType<IEncryption,PoorMansEncryption>() ; _encryption = _container.Resolve<IEncryption>(); }
public static PeerMessage ReceiveMessage(CustomConnection connection, IEncryption decryptor, TorrentManager manager) { byte[] buffer = new byte[4]; Receive (connection, buffer, 0, buffer.Length); decryptor.Decrypt(buffer); int count = IPAddress.HostToNetworkOrder(BitConverter.ToInt32(buffer, 0)); byte[] message = new byte[count + 4]; Buffer.BlockCopy(buffer, 0, message, 0, 4); Receive (connection, message, 4, count); decryptor.Decrypt(message, 4, count); return PeerMessage.DecodeMessage(message, 0, message.Length, manager); }
/// <summary> /// Signals to the endgine to change its method of encryption/decryption /// </summary> /// <param name="engineNumber">1-rot13 2-string reverse</param> /// TODO Chnage this to an enum? public void ChangeEngine(int engineNumber) { switch (engineNumber) { case 1: currentEngine = new Rot13(); break; case 2: currentEngine = new StringReverse(); break; default: currentEngine = new Rot13(); break; } }
public void Setup(bool metadataMode, string metadataPath) { pair = new ConnectionPair(55432); rig = TestRig.CreateSingleFile(1024 * 1024 * 1024, 32768, metadataMode); rig.MetadataPath = metadataPath; rig.RecreateManager(); rig.Manager.HashChecked = true; rig.Manager.Start(); rig.AddConnection(pair.Outgoing); var connection = pair.Incoming; PeerId id = new PeerId(new Peer("", connection.Uri), rig.Manager); id.Connection = connection; byte[] data; EncryptorFactory.EndCheckEncryption(EncryptorFactory.BeginCheckEncryption(id, 68, null, null, new InfoHash[] { id.TorrentManager.InfoHash }), out data); decryptor = id.Decryptor; encryptor = id.Encryptor; }
public static Stream BytesToStream(string data, IEncryption encryption) { var convertedBytes = data.AsBytes(); byte[] createdBuffer; if (encryption != null) { createdBuffer = new byte[convertedBytes.Length + 2]; createdBuffer[0] = createdBuffer[1] = 0xFF; var encryptedBuffer = encryption.EncryptBytes(convertedBytes); encryptedBuffer.CopyTo(createdBuffer, 2); } else { createdBuffer = convertedBytes; } Stream memoryStream = new MemoryStream(); memoryStream.Write(createdBuffer, 0, createdBuffer.Length); memoryStream.Seek(0, SeekOrigin.Begin); return memoryStream; }
public WmiClient(ILog log, Job job, IEncryption encryption) : base(log, job, encryption) { this.machineName = Environment.MachineName; this.WireUpProperties(job, this); }
public UserService(IDatabaseProvider databaseProvider, IEncryption encryption) { _db = databaseProvider.GetDb(); _encryption = encryption; }
public HttpPing(ILog log, Job job, IEncryption encryption) : base(log, job, encryption) { }
public DataClientFactory(ILog log, IAssemblyResolver assemblyResolver, IEncryption encryption) { this.log = log; this.assemblyResolver = assemblyResolver; this.encryption = encryption; }
public void InitiateTransfer(CustomConnection connection) { PeerId id = new PeerId(new Peer("", connection.Uri), rig.Manager); id.Connection = connection; id.recieveBuffer = new ArraySegment<byte>(new byte[68]); byte[] data = id.recieveBuffer.Array; id.BytesToRecieve = 68; EncryptorFactory.EndCheckEncryption(EncryptorFactory.BeginCheckEncryption(id, null, null, new byte[][] {id.TorrentManager.Torrent.infoHash }), out data); decryptor = id.Decryptor; encryptor = id.Encryptor; TestHandshake(data, connection); }
public void SetUp() { m_DummyEncryption = new XOREncryption(new XORKey(new byte[] { 0x01 })); }
/// <summary> /// Constructor /// </summary> public EncryptionEngine() { //Set a default engine in case encrypt/decrypt are called before changeEngine //Too lazy to throw exceptions currentEngine=new Rot13(); }
public EncryptedByteStream(Stream stream, IEncryption encryption) : base(stream) { Encryption = encryption; }