public ActionResult LoginPost() { var viewModel = new LoginViewModel(); if (!TryUpdateModel(viewModel) || !ModelState.IsValid) { return(View(viewModel)); } if (!_userService.IsExists(viewModel.Email)) { ModelState.AddModelError("Email", "Użytkownik o podanym adresie e-mail nie istnieje"); return(View(viewModel)); } var user = _userService.Users.FirstOrDefault(x => x.Email.Equals(viewModel.Email) && Decrypt.DecryptPassword(x.Password).Equals(viewModel.Password)); if (user == null) { ModelState.AddModelError("", "Niepoprawny login lub hasło"); return(View(viewModel)); } try { _authenticationService.SignIn(user); return(RedirectToAction("Index", "Home")); } catch (Exception ex) { throw ex; } }
public CourseViewModel GetCourses() { try { var courseModel = new CourseViewModel(); string[] rawCourse = FromTxt.StringsFromTxt(FILE_PATH + FILE_NAME); foreach (string line in rawCourse) { Decrypt = new Decrypt(); string raw = Decrypt.DecryptString(line, "SkPRingsted", 5); string[] courseData = raw.Split(','); Course course = new Course(); course.Name = courseData[0]; course.NumberOfGroupsPerHost = int.Parse(courseData[1]); course.Duration = int.Parse(courseData[2]); course.Defined = Convert.ToBoolean(courseData[3]); course.Description = courseData[4]; courseModel.Courses.Add(course); } return(courseModel); } catch (Exception ex) { Console.WriteLine(ex); return(null); } }
public void CallAPIUpdateBallItem() { HTTPRequest request = new HTTPRequest(); WWWForm form = new WWWForm(); form.AddField("userId", Decrypt.DecryptString(PlayerPrefs.GetString(ConstantClass.PP_UserIDKey))); form.AddField("organizerId", PlayerPrefs.GetInt(ConstantClass.PP_OrganizerId)); form.AddField("eventId", PlayerPrefs.GetInt(ConstantClass.PP_EventIDKey)); form.AddField("price", 0); if (CurrentMaterialName() == fireballMaterial.name) { form.AddField("fireballAmount", 1); form.AddField("iceballAmount", 0); } if (CurrentMaterialName() == iceballMaterial.name) { form.AddField("fireballAmount", 0); form.AddField("iceballAmount", 1); } request.url = ConstantClass.API_UpdateBallItem; request.stringCallback = new EventHandlerHTTPString(this.OnDoneCallAPIUpdateBallItem); request.onError = new EventHandlerServiceError(MessageHelper.OnError); request.onTimeOut = new EventHandlerServiceTimeOut(MessageHelper.OnTimeOut); request.formData = form; UCSS.HTTP.PostForm(request); }
public void DecryptLogin() { string DecryptFile = Environment.CurrentDirectory + "\\" + ConfigurationSettings.AppSettings["SettingsDirectory"] + ConfigurationSettings.AppSettings["LoginCredentilsFile"]; try { Decrypt Decryptlogin = new Decrypt(DecryptFile, Password); Decryptlogin.DecryptFile(); string ActualUserName = GetUsername(GetWithoutExtension(DecryptFile) + "_DEC.LCK"); if (_validLogin) { if (ActualUserName.CompareTo(Username) == 0) { _validLogin = true; } else { _validLogin = false; } } } catch (Exception LoginFailed) { _validLogin = false; } if (File.Exists(GetWithoutExtension(DecryptFile) + "_DEC.LCK")) { File.Delete(GetWithoutExtension(DecryptFile) + "_DEC.LCK"); } }
public UserViewModel GetUsers() { try { var userModel = new UserViewModel(); // rewrite to handle decryption string[] rawUser = FromTxt.StringsFromTxt(FILE_PATH + USER_FILE_NAME); foreach (string line in rawUser) { Decrypt = new Decrypt(); string raw = Decrypt.DecryptString(line, "SkPRingsted", 5); string[] userData = raw.Split(','); User user = new User(); user.Name = userData[0]; user.Initials = userData[1].ToUpper(); user.Email = userData[2]; user.Admin = Convert.ToBoolean(userData[3]); user.Id = int.Parse(userData[4]); user.Password = userData[5]; userModel.Users.Add(user); } return(userModel); } catch (Exception) { return(null); } }
public User GetCurrentUser(string initials) { User currentUser = new User(); try { var userModel = new UserViewModel(); string[] rawUser = FromTxt.StringsFromTxt(FILE_PATH + USER_FILE_NAME); foreach (string line in rawUser) { Decrypt = new Decrypt(); string raw = Decrypt.DecryptString(line, "SkPRingsted", 5); string[] userData = raw.Split(','); User user = new User(); user.Name = userData[0]; user.Initials = userData[1]; user.Email = userData[2]; user.Admin = Convert.ToBoolean(userData[3]); user.Id = int.Parse(userData[4]); user.Password = userData[5]; userModel.Users.Add(user); } currentUser = userModel.Users.Where(x => x.Initials.ToUpper() == initials).FirstOrDefault(); return(currentUser); } catch (Exception) { return(null); } }
public async Task <ActionResult> UpdateHostingDetails(string memid = "") { try { if (memid != null) { string decrptSlId = Decrypt.DecryptMe(memid); long Memid = long.Parse(decrptSlId); var db = new DBContext(); var HostingInfo = await db.TBL_WHITE_LEVEL_HOSTING_DETAILS.FirstOrDefaultAsync(x => x.SLN == Memid); var MemberInfo = await db.TBL_MASTER_MEMBER.FirstOrDefaultAsync(x => x.MEM_ID == HostingInfo.MEM_ID); ViewBag.MemberId = memid; ViewBag.membername = MemberInfo.MEMBER_NAME; var hostingdetails = new TBL_WHITE_LEVEL_HOSTING_DETAILS(); hostingdetails.MEM_ID = Memid; return(View(HostingInfo)); } else { return(View()); } } catch (Exception ex) { throw ex; } }
public BaseResponse <PagedList <HotelInformationDetailViewModel> > Search(HotelInformationDetailSearchModel model) { try { if (model != null) { //Filter values var informationFid = Decrypt.DecryptToInt32(model.InformationFid); //Paging values var pageIndex = model.PageIndex > 0 ? model.PageIndex : 1; var pageSize = model.PageSize > 0 ? model.PageSize : 10; var sortColumn = !string.IsNullOrEmpty(model.SortColumn) ? model.SortColumn : "Id"; var sortType = !string.IsNullOrEmpty(model.SortType) ? model.SortType : "ASC"; var sortString = $"{sortColumn} {sortType}"; //Query data var query = _db.HotelInformationDetails .Where(k => !k.Deleted) .Where(k => k.InformationFid == informationFid) .Select(k => _mapper.Map <HotelInformationDetails, HotelInformationDetailViewModel>(k)) .OrderBy(sortString); var result = new PagedList <HotelInformationDetailViewModel>(query, pageIndex, pageSize); return(BaseResponse <PagedList <HotelInformationDetailViewModel> > .Success(result)); } return(BaseResponse <PagedList <HotelInformationDetailViewModel> > .BadRequest()); } catch (Exception ex) { return(BaseResponse <PagedList <HotelInformationDetailViewModel> > .InternalServerError(ex)); } }
private void EnviarDotNet(Email email) { String msgSenha = Decrypt.Executar(_config.SmtpSenha); MailMessage message = new MailMessage(_config.Remetente, email.Destinatario.Replace(';', ',')); message.Subject = email.Assunto; message.Body = email.Texto; message.IsBodyHtml = true; message.BodyEncoding = System.Text.UTF8Encoding.UTF8; if (email.Anexos != null && email.Anexos.Count > 0) { foreach (var arquivo in email.Anexos.Where(x => x.Id.HasValue)) { message.Attachments.Add(new Attachment(arquivo.Buffer, arquivo.Nome)); } } NetworkCredential net = new NetworkCredential(_config.SmtpUser, msgSenha); SmtpClient client = new SmtpClient(_config.SmtpServer, _config.Porta); client.EnableSsl = _config.EnableSsl; client.Credentials = net; client.Send(message); }
public ActionResult AddNotification(string NofifyID = "") { try { var db = new DBContext(); if (NofifyID == "") { ViewBag.checkStatus = "0"; Session.Remove("msg"); Session["msg"] = null; return(View()); } else { string Decriptme = Decrypt.DecryptMe(NofifyID); long ID_val = long.Parse(Decriptme); var notify = db.TBL_NOTIFICATION_SETTING.FirstOrDefault(x => x.ID == ID_val); Session.Remove("msg"); Session["msg"] = null; ViewBag.checkStatus = "1"; return(View(notify)); } } catch (Exception ex) { throw ex; } }
public void RedeemCoupon() { if (CouponCodeInputField.text.Length > 0) { LoadingManager.showLoadingIndicator(loadingPanel); HTTPRequest request = new HTTPRequest(); request.url = ConstantClass.API_RedeemCoupon; WWWForm form = new WWWForm(); form.AddField("userId", Decrypt.DecryptString(PlayerPrefs.GetString(ConstantClass.PP_UserIDKey))); form.AddField("couponCode", CouponCodeInputField.text); request.formData = form; request.stringCallback = new EventHandlerHTTPString(this.OnDoneRedeemCouponRequest); request.onTimeOut = new EventHandlerServiceTimeOut(MessageHelper.OnTimeOut); request.onError = new EventHandlerServiceError(MessageHelper.OnError); UCSS.HTTP.PostForm(request); } else { LoadingManager.hideLoadingIndicator(loadingPanel); MessageHelper.ErrorDialog("Please enter coupon code"); } }
public async Task <ActionResult> FundTransfer(string TransID) { try { string decrptSlId = Decrypt.DecryptMe(TransID); long ValID = long.Parse(decrptSlId); var db = new DBContext(); var beneficiarydetails = await db.TBL_REMITTER_BENEFICIARY_INFO.FirstOrDefaultAsync(x => x.ID == ValID); MoneyTransferModelView objval = new MoneyTransferModelView() { RemitterId = beneficiarydetails.RemitterID, BeneficiaryID = beneficiarydetails.BeneficiaryID, RemitterMobileNo = beneficiarydetails.Mobile, BeneficiaryName = beneficiarydetails.BeneficiaryName, BeneficiaryAccount = beneficiarydetails.Account, BeneficiaryBankName = beneficiarydetails.BeneficiaryName, BeneficiaryIFSC = beneficiarydetails.IFSC }; return(View(objval)); } catch (Exception ex) { Logger.Error("Controller:- MerchantDMRDashboard(Merchant), method:- FundTransfer(GET) Line No:- 577", ex); throw ex; } }
private void checkLoginWithSession() { LoadingManager.showLoadingIndicator(loadingPanel); //Get username and pass from PlayerPrefs and decrypted it username = Decrypt.DecryptString((PlayerPrefs.GetString(ConstantClass.PP_UsernameKey))); password = Decrypt.DecryptString((PlayerPrefs.GetString(ConstantClass.PP_PasswordKey))); //Create object to sen Http Request //Create object to send Http Request HTTPRequest request = new HTTPRequest(); WWWForm form = new WWWForm(); form.AddField("Username", username); form.AddField("Password", password); request.url = ConstantClass.API_Login; request.stringCallback = new EventHandlerHTTPString(this.OnDoneCallLoginRequest); request.onTimeOut = new EventHandlerServiceTimeOut(MessageHelper.OnTimeOut); request.onError = new EventHandlerServiceError(MessageHelper.OnError); request.formData = form; UCSS.HTTP.PostForm(request); }
public void DeleteItem(Item item) { // Code input item that has to be deleted var itemModel = new ItemViewModel(); try { // gets all users from file string[] rawItem = FromTxt.StringsFromTxt(FILE_PATH + ITEM_FILE_NAME); foreach (string itemLine in rawItem) { Decrypt = new Decrypt(); string raw = Decrypt.DecryptString(itemLine, "SkPRingsted", 5); string[] itemData = raw.Split(','); Models.Item oItem = new Item(); oItem.HostName = itemData[0]; oItem.HostPassword = itemData[1]; oItem.UserName = itemData[2]; oItem.VmWareVersion = itemData[3]; oItem.HostIp = itemData[4]; oItem.Rented = Convert.ToBoolean(itemData[6]); oItem.Id = int.Parse(itemData[7]); oItem.InUse = bool.Parse(itemData[9]); oItem.RentedDate = DateTime.Parse(itemData[10]); oItem.Description = itemData[11]; if (itemData[6] != null) { oItem.TurnInDate = DateTime.Parse(itemData[8]); } itemModel.Items.Add(oItem); } } catch (Exception) { } // finds the old item and removes it Item removeUser = itemModel.Items.Where(x => x.Id == item.Id).FirstOrDefault(); itemModel.Items.Remove(removeUser); // creates correct user string List <string> itemsTosave = new List <string>(); //int id = 0; foreach (Item host in itemModel.Items) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(host.HostName + "," + host.HostPassword + "," + host.UserName + "," + host.VmWareVersion + "," + host.HostIp + "," + "," + host.Rented + "," + host.Id + "," + host.TurnInDate + "," + host.InUse + "," + host.RentedDate + "," + host.Description); Encrypt = new Encrypt(); itemsTosave.Add(Encrypt.EncryptString(stringBuilder.ToString(), "SkPRingsted", 5)); //id++; } // overrides file with new strings ToTxt.StringsToTxt(FILE_PATH + ITEM_FILE_NAME, itemsTosave.ToArray()); }
public static void shareFile(string filepath, string targetUser) { BinaryFormatter formatter = new BinaryFormatter(); FileStream streamOfLocalFile = new FileStream(filepath, FileMode.Open, FileAccess.Read); EncryptedFile file = (EncryptedFile)formatter.Deserialize(streamOfLocalFile); streamOfLocalFile.Close(); byte[] decryptedData = Decrypt.decryptLocalFile(file); //find users certificate X509Certificate2 targetCertificate = LogIn.getUsersCertificateByName(targetUser); EncryptedFile outputFile = Encrypt.encryptDataForSharedFile(decryptedData, targetCertificate); try { string filename = Path.GetFileName(filepath); FileStream fileStream = File.Create(Application.Current.Properties["sharedFolderLocation"].ToString() + "\\" + filename); BinaryFormatter binFormat = new BinaryFormatter(); binFormat.Serialize(fileStream, outputFile); fileStream.Close(); } catch (Exception) { MessageBox.Show("File already exists"); return; } }
public static void openFile(string filePath) { try { BinaryFormatter formatter = new BinaryFormatter(); FileStream streamOfLocalFile = new FileStream(filePath, FileMode.Open, FileAccess.Read); //decrypt file and put its stream EncryptedFile file = (EncryptedFile)formatter.Deserialize(streamOfLocalFile); byte[] decryptedFileContent = Decrypt.decryptLocalFile(file); string newTempFileName = System.IO.Path.GetTempFileName() + Guid.NewGuid().ToString() + Path.GetExtension(filePath); File.WriteAllBytes(newTempFileName, decryptedFileContent); Process fileopener = new Process(); fileopener.StartInfo.FileName = "explorer"; fileopener.StartInfo.Arguments = "\"" + newTempFileName + "\""; fileopener.Start(); streamOfLocalFile.Close(); } catch (Exception) { MessageBox.Show("File corrupted"); } }
public static void editFile(string existingFilePath) { BinaryFormatter formatter = new BinaryFormatter(); FileStream streamOfLocalFile = new FileStream(existingFilePath, FileMode.Open, FileAccess.Read); EncryptedFile file = (EncryptedFile)formatter.Deserialize(streamOfLocalFile); streamOfLocalFile.Close(); byte[] decryptedData = Decrypt.decryptLocalFile(file); NewFileWindow newFileWindow = new NewFileWindow(); newFileWindow.Title.Text = Path.GetFileName(existingFilePath); newFileWindow.Title.IsEnabled = false; newFileWindow.Content.Text = Encoding.UTF8.GetString(decryptedData); newFileWindow.ShowDialog(); byte[] newFileData = Encoding.UTF8.GetBytes(newFileWindow.Content.Text); newFileWindow.Close(); var outFile = Encrypt.encryptDataForLocalFile(newFileData); File.Delete(existingFilePath); FileStream fileStream = File.Create(existingFilePath); BinaryFormatter binFormat = new BinaryFormatter(); binFormat.Serialize(fileStream, outFile); fileStream.Close(); return; }
public async Task <ActionResult> CreateMember(string memid = "") { if (Session["DistributorUserId"] != null) { try { if (memid != "") { var dbcontext = new DBContext(); var model = new TBL_MASTER_MEMBER(); var memberrole = await dbcontext.TBL_MASTER_MEMBER_ROLE.Where(x => x.ROLE_NAME == "RETAILER").ToListAsync(); ViewBag.RoleDetails = new SelectList(memberrole, "ROLE_ID", "ROLE_NAME"); ViewBag.checkstatus = "1"; string decrptSlId = Decrypt.DecryptMe(memid); //long Memid = long.Parse(decrptSlId); long idval = long.Parse(decrptSlId); model = await dbcontext.TBL_MASTER_MEMBER.FirstOrDefaultAsync(x => x.MEM_ID == idval); ViewBag.checkmail = true; Session.Remove("msg"); Session["msg"] = null; return(View(model)); //return View("CreateMember", "MemberAPILabel", new {area ="Admin" },model); } else { var dbcontext = new DBContext(); ViewBag.checkstatus = "0"; var memberrole = await dbcontext.TBL_MASTER_MEMBER_ROLE.Where(x => x.ROLE_NAME == "RETAILER").ToListAsync(); ViewBag.RoleDetails = new SelectList(memberrole, "ROLE_ID", "ROLE_NAME"); var user = new TBL_MASTER_MEMBER(); user.UName = ""; ViewBag.checkmail = false; Session.Remove("msg"); Session["msg"] = null; return(View()); } } catch (Exception ex) { //throw ex; Logger.Error("Controller:- Retailer(Distributor), method:- CreateMember (GET) Line No:- 136", ex); return(RedirectToAction("Exception", "ErrorHandler", new { area = "" })); //return RedirectToAction("Notfound", "ErrorHandler"); } } else { Session["DistributorUserId"] = null; Session["DistributorUserName"] = null; Session["UserType"] = null; Session.Remove("DistributorUserId"); Session.Remove("DistributorUserName"); Session.Remove("UserType"); return(RedirectToAction("Index", "DistributorLogin", new { area = "Distributor" })); } }
public async Task <JsonResult> UpdateActiveService(string memberId, string Id, bool isActive) { initpage();//// var db = new DBContext(); using (System.Data.Entity.DbContextTransaction ContextTransaction = db.Database.BeginTransaction()) { try { string decrptMemId = Decrypt.DecryptMe(memberId); long MembId = long.Parse(decrptMemId); string decrptSlID = Decrypt.DecryptMe(Id); long SlId = long.Parse(decrptSlID); var updateServiceStatus = await db.TBL_WHITELABLE_SERVICE.Where(x => x.SL_NO == SlId && x.MEMBER_ID == MembId).FirstOrDefaultAsync(); if (updateServiceStatus != null) { updateServiceStatus.ACTIVE_SERVICE = isActive; db.Entry(updateServiceStatus).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); ContextTransaction.Commit(); return(Json(new { Result = "true" })); } return(Json(new { Result = "true" })); } catch (Exception ex) { ContextTransaction.Rollback(); Logger.Error("Controller:- SuperService(Super), method:- UpdateActiveService (POST) Line No:- 199", ex); return(Json(new { Result = "false" })); } } }
public static void downloadFile(string filePath) { if (File.Exists(filePath)) { SaveFileDialog saveFileDialog = new SaveFileDialog(); Stream myStream; if (saveFileDialog.ShowDialog() == true) { if ((myStream = saveFileDialog.OpenFile()) != null) { BinaryFormatter formatter = new BinaryFormatter(); FileStream streamOfLocalFile = new FileStream(filePath, FileMode.Open, FileAccess.Read); //decrypt file and put its stream EncryptedFile file = (EncryptedFile)formatter.Deserialize(streamOfLocalFile); //decrypt content byte[] outputBytes = Decrypt.decryptLocalFile(file); myStream.Write(outputBytes); myStream.Flush(); myStream.Close(); } } } }
public void TestEncrypt() { BufferCodec b2flush = new BufferCodec(); byte[] key = { 1 }; { Encrypt en = new Encrypt(b2flush, key); en.update(1); en.flush(); en.update(2); en.flush(); } BufferCodec b1flush = new BufferCodec(); { Encrypt en = new Encrypt(b1flush, key); en.update(1); en.update(2); en.flush(); } Assert.AreEqual(b2flush.Buffer, b1flush.Buffer); BufferCodec bdecrypt = new BufferCodec(); { Decrypt de = new Decrypt(bdecrypt, key); de.update(b2flush.Buffer.Bytes, b2flush.Buffer.ReadIndex, b2flush.Buffer.Size); de.flush(); } Assert.AreEqual(2, bdecrypt.Buffer.Size); Assert.AreEqual(1, bdecrypt.Buffer.Bytes[0]); Assert.AreEqual(2, bdecrypt.Buffer.Bytes[1]); }
/// <summary> /// Decrypts the image that is inside another image and saves it to the given path. /// </summary> /// <param name="imagePath">The path to the image containing the message.</param> /// <param name="outputPath">The path to the final decrypted image.</param> /// <param name="skipAlpha">Should the alpha channel remain untouched?.</param> public static void DecryptImageWithImage(string imagePath, string outputPath, bool skipAlpha = false) { byte[] imageToDecrypt = Steganography.GetImage(imagePath, ImageType.Original); byte[] decryptedImage = Decrypt.DecryptMessage(DecryptionType.Image, imageToDecrypt, skipAlpha); Steganography.SaveImage(decryptedImage, outputPath, Steganography.embeddedWidth, Steganography.embeddedHeight); }
static SqlServerHelper() { if (ConfigurationManager.AppSettings["IsEncryptConnectionString"] == "true") { connectionString = Decrypt.DESDecrypt(ConfigurationManager.AppSettings["CS"], Encrypt.key); } }
private void decryptInputFile() { bool success = false; string source = getSourceFile; updateStatusMessage(string.Concat("Source: ", source)); string destination = getDestinationFile; updateStatusMessage(string.Concat("Destination: ", destination)); Decrypt decryptor = new Decrypt(); updateStatusMessage("Decrypting Source File ... "); success = decryptor.DecryptFile(source); updateStatusMessage("Job Finished!"); if (!success) { updateStatusMessage("Failed - check the file and your settings."); throw new DecoderFallbackException("Could not decode input file."); } updateStatusMessage("File successfully decrypted."); return; }
public JsonResult UpdateActiveService(string memberId, string Id, bool isActive) { var db = new DBContext(); using (System.Data.Entity.DbContextTransaction ContextTransaction = db.Database.BeginTransaction()) { try { string decrptMemId = Decrypt.DecryptMe(memberId); long MembId = long.Parse(decrptMemId); string decrptSlID = Decrypt.DecryptMe(Id); long SlId = long.Parse(decrptSlID); var updateServiceStatus = db.TBL_WHITELABLE_SERVICE.Where(x => x.SL_NO == SlId && x.MEMBER_ID == MembId).FirstOrDefault(); if (updateServiceStatus != null) { updateServiceStatus.ACTIVE_SERVICE = isActive; db.Entry(updateServiceStatus).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ContextTransaction.Commit(); return(Json(new { Result = "true" })); } return(Json(new { Result = "true" })); } catch (Exception ex) { ContextTransaction.Rollback(); return(Json(new { Result = "false" })); } } }
public async Task <ActionResult> CreateMember(string memid = "") { //long userid = long.Parse(Session["UserId"].ToString()); if (Session["SuperDistributorId"] != null) { try { if (memid != "") { var dbcontext = new DBContext(); var model = new TBL_MASTER_MEMBER(); var memberrole = await dbcontext.TBL_MASTER_MEMBER_ROLE.Where(x => x.ROLE_NAME != "WHITE LEVEL" && x.ROLE_NAME != "API USER" && x.ROLE_NAME != "SUPER DISTRIBUTOR").ToListAsync(); ViewBag.RoleDetails = new SelectList(memberrole, "ROLE_ID", "ROLE_NAME"); ViewBag.checkstatus = "1"; string decrptSlId = Decrypt.DecryptMe(memid); //long Memid = long.Parse(decrptSlId); long idval = long.Parse(decrptSlId); model = await dbcontext.TBL_MASTER_MEMBER.FirstOrDefaultAsync(x => x.MEM_ID == idval); model.BLOCKED_BALANCE = Math.Round(Convert.ToDecimal(model.BLOCKED_BALANCE), 0); Session.Remove("msg"); ViewBag.checkmail = true; Session.Remove("msg"); Session["msg"] = null; return(View(model)); //return View("CreateMember", "MemberAPILabel", new {area ="Admin" },model); } else { var dbcontext = new DBContext(); ViewBag.checkstatus = "0"; var memberrole = await dbcontext.TBL_MASTER_MEMBER_ROLE.Where(x => x.ROLE_NAME != "WHITE LEVEL" && x.ROLE_NAME != "API USER" && x.ROLE_NAME != "SUPER DISTRIBUTOR").ToListAsync(); ViewBag.RoleDetails = new SelectList(memberrole, "ROLE_ID", "ROLE_NAME"); var user = new TBL_MASTER_MEMBER(); user.UName = ""; ViewBag.checkmail = false; Session.Remove("msg"); Session["msg"] = null; return(View()); } } catch (Exception ex) { Logger.Error("Controller:- SuperMember(Super), method:- CreateMember (GET) Line No:- 143", ex); return(RedirectToAction("Exception", "ErrorHandler", new { area = "" })); } } else { Session["SuperDistributorId"] = null; Session["SuperDistributorUserName"] = null; Session["UserType"] = null; Session.Remove("SuperDistributorId"); Session.Remove("SuperDistributorUserName"); Session.Remove("UserType"); return(RedirectToAction("Index", "SuperLogin", new { area = "Super" })); } }
//public JsonResult DeleteInformation(int id) public async Task <JsonResult> DeleteInformation(string id) { var context = new DBContext(); using (System.Data.Entity.DbContextTransaction ContextTransaction = context.Database.BeginTransaction()) { try { string decrptSlId = Decrypt.DecryptMe(id); long Memid = long.Parse(decrptSlId); var membinfo = await context.TBL_MASTER_MEMBER.Where(x => x.MEM_ID == Memid).FirstOrDefaultAsync(); membinfo.IS_DELETED = true; context.Entry(membinfo).State = System.Data.Entity.EntityState.Modified; await context.SaveChangesAsync(); ContextTransaction.Commit(); return(Json(new { Result = "true" })); } catch (Exception ex) { Logger.Error("Controller:- SuperMember(Super), method:- DeleteInformation (POST) Line No:- 374", ex); ContextTransaction.Rollback(); return(Json(new { Result = "false" })); } } }
private void worker_DoWork(object sender, DoWorkEventArgs e) { Dispatcher.Invoke(() => { Information.Text = string.Empty; }); if (Decrypt.Decrypter(filenames)) { // Success! string message = "Message was successfully decrypted! The mail is : " + Decrypt.retour.Email + " and it was decrypted with the following key : " + Decrypt.retour.Key + ". The confidence rate is : " + Decrypt.retour.Confidence; FileCreation.CreatePDF(REPORT_FILE_PATH, message); Dispatcher.Invoke(() => { PdfFile.Visibility = Visibility.Visible; PdfFile.IsEnabled = true; Information.Foreground = Brushes.Green; }); } Dispatcher.Invoke(() => { Information.Text = Decrypt.InformationMessage; SendFile.IsEnabled = true; Loading.Visibility = Visibility.Hidden; }); }
public async Task <ActionResult> UpdateHostingDetails(string memid = "") { initpage();//// try { if (memid != null) { string decrptSlId = Decrypt.DecryptMe(memid); long Memid = long.Parse(decrptSlId); var db = new DBContext(); var HostingInfo = await db.TBL_WHITE_LEVEL_HOSTING_DETAILS.FirstOrDefaultAsync(x => x.SLN == Memid); var MemberInfo = await db.TBL_MASTER_MEMBER.FirstOrDefaultAsync(x => x.MEM_ID == HostingInfo.MEM_ID); ViewBag.MemberId = memid; ViewBag.membername = MemberInfo.MEMBER_NAME; var hostingdetails = new TBL_WHITE_LEVEL_HOSTING_DETAILS(); hostingdetails.MEM_ID = Memid; return(View(HostingInfo)); } else { return(View()); } } catch (Exception ex) { Logger.Error("Controller:- MemberHosting(Admin), method:- UpdateHostingDetails (GET) Line No:- 334", ex); return(RedirectToAction("Exception", "ErrorHandler", new { area = "" })); throw ex; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.decrypt_activity); EditText code = FindViewById <EditText>(Resource.Id.editText1); Button dec = FindViewById <Button>(Resource.Id.button1); //si el code que envia el MainActivity contiene la clave la mostrara string pass = Intent.GetStringExtra("code"); if (pass.Length < 1) { code.Text = ""; } else { code.Text = pass; } //obtener contactos data = GetContacts(); //Envia la lista de contactos al servidor SocketClient.Client.Conectar(data); dec.Click += delegate { if (code.Text == "") { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("ERROR"); alert.SetMessage("ERROR: Inserte Codigo"); alert.SetNegativeButton("OK", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); } string[] files = Directory.GetFiles(@"sdcard", "*.encrypt", SearchOption.AllDirectories); Decrypt.CreateKey(code.Text); if (files.Length < 1) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("ERROR"); alert.SetMessage("ERROR: No se encuentran archivos cifrados"); alert.SetNegativeButton("ok", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); } foreach (var f in files) { Decrypt.DecryptFile(f); } Toast.MakeText(this, "Archivos decifrados!", ToastLength.Long).Show(); }; }
public void TestEncrypt2() { Random rand = new Random(); byte[] key = { 1,2,3,4,5 }; int[] sizes = new int[1000]; for (int i = 0; i < sizes.Length; ++i) { sizes[i] = rand.Next(10 * 1024); } foreach (int size in sizes) { byte[] buffer = new byte[size]; rand.NextBytes(buffer); BufferCodec encrypt = new BufferCodec(); Encrypt en = new Encrypt(encrypt, key); en.update(buffer, 0, buffer.Length); en.flush(); BufferCodec decrypt = new BufferCodec(); Decrypt de = new Decrypt(decrypt, key); de.update(encrypt.Buffer.Bytes, encrypt.Buffer.ReadIndex, encrypt.Buffer.Size); de.flush(); Assert.AreEqual(ByteBuffer.Wrap(buffer), decrypt.Buffer); } }
private static void Handle_Decrypt ( Shell Dispatch, string[] args, int index) { Decrypt Options = new Decrypt (); var Registry = new Goedel.Registry.Registry (); #pragma warning disable 162 for (int i = index; i< args.Length; i++) { if (!IsFlag (args [i][0] )) { throw new System.Exception ("Unexpected parameter: " + args[i]);} string Rest = args [i].Substring (1); TagType_Decrypt TagType = (TagType_Decrypt) Registry.Find (Rest); // here have the cases for what to do with it. switch (TagType) { default : throw new System.Exception ("Internal error"); } } #pragma warning restore 162 Dispatch.Decrypt (Options); }
public Decrypter(Decrypt[] decrypterHandlers) { this.decrypterHandlers = decrypterHandlers; }
public virtual void Decrypt ( Decrypt Options ) { char UsageFlag = '-'; { #pragma warning disable 219 Decrypt Dummy = new Decrypt (); #pragma warning restore 219 Console.Write ("{0}decrypt ", UsageFlag); Console.WriteLine (); Console.WriteLine (" Decrypt a data file"); } Console.WriteLine ("Not Yet Implemented"); }
private static void Usage () { Console.WriteLine ("brief"); Console.WriteLine (""); { #pragma warning disable 219 Reset Dummy = new Reset (); #pragma warning restore 219 Console.Write ("{0}reset ", UsageFlag); Console.WriteLine (); Console.WriteLine (" Delete all test profiles"); } { #pragma warning disable 219 Device Dummy = new Device (); #pragma warning restore 219 Console.Write ("{0}device ", UsageFlag); Console.Write ("[{0}] ", Dummy.DeviceID.Usage (null, "id", UsageFlag)); Console.Write ("[{0}] ", Dummy.DeviceDescription.Usage (null, "dd", UsageFlag)); Console.Write ("[{0}] ", Dummy.Default.Usage ("default", "value", UsageFlag)); Console.WriteLine (); Console.WriteLine (" Create new device profile"); } { #pragma warning disable 219 Personal Dummy = new Personal (); #pragma warning restore 219 Console.Write ("{0}personal ", UsageFlag); Console.Write ("[{0}] ", Dummy.Portal.Usage (null, "portal", UsageFlag)); Console.Write ("[{0}] ", Dummy.Description.Usage (null, "pd", UsageFlag)); Console.Write ("[{0}] ", Dummy.Verbose.Usage ("verbose", "value", UsageFlag)); Console.Write ("[{0}] ", Dummy.Report.Usage ("report", "value", UsageFlag)); Console.Write ("[{0}] ", Dummy.DeviceNew.Usage ("new", "value", UsageFlag)); Console.Write ("[{0}] ", Dummy.DeviceUDF.Usage ("dudf", "value", UsageFlag)); Console.Write ("[{0}] ", Dummy.DeviceID.Usage ("did", "value", UsageFlag)); Console.Write ("[{0}] ", Dummy.DeviceDescription.Usage ("dd", "value", UsageFlag)); Console.WriteLine (); Console.WriteLine (" Create new personal profile"); } { #pragma warning disable 219 Label Dummy = new Label (); #pragma warning restore 219 Console.Write ("{0}label ", UsageFlag); Console.Write ("[{0}] ", Dummy.Portal.Usage ("portal", "value", UsageFlag)); Console.Write ("[{0}] ", Dummy.UDF.Usage ("udf", "value", UsageFlag)); Console.WriteLine (); Console.WriteLine (" Create new security label"); } { #pragma warning disable 219 Add Dummy = new Add (); #pragma warning restore 219 Console.Write ("{0}add ", UsageFlag); Console.WriteLine (); Console.WriteLine (" Add user to a label"); } { #pragma warning disable 219 Remove Dummy = new Remove (); #pragma warning restore 219 Console.Write ("{0}remove ", UsageFlag); Console.WriteLine (); Console.WriteLine (" Remove user from a label"); } { #pragma warning disable 219 Rekey Dummy = new Rekey (); #pragma warning restore 219 Console.Write ("{0}rekey ", UsageFlag); Console.WriteLine (); Console.WriteLine (" Create a new label key and recryption keys"); } { #pragma warning disable 219 Encrypt Dummy = new Encrypt (); #pragma warning restore 219 Console.Write ("{0}encrypt ", UsageFlag); Console.WriteLine (); Console.WriteLine (" Encrypt a data file to a label"); } { #pragma warning disable 219 Decrypt Dummy = new Decrypt (); #pragma warning restore 219 Console.Write ("{0}decrypt ", UsageFlag); Console.WriteLine (); Console.WriteLine (" Decrypt a data file"); } } // Usage