728x90 반응형 C#72 네이버 스마트에디터] 이미지파일 업로드시 Base64인코딩 태그로 수정 1. Controllers/WebEditorController.cs – 파일첨부 2. Views/Shared/WebEditor.ascx – 아래 함수 추가 //base64 이미지삽입 - 업로드 완료페이지에서 호출됨. function insertIMGBase64(fileAsString) { var sHTML = ""; oEditors.getById["ir1"].exec("PASTE_HTML", [sHTML]); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult ImgUpload(string ckhBorder, HttpPostedFileBase update_image) { string filePath = Request.Form["filePath"].ToString(.. 2021. 9. 6. C#] JWT, JSON Web Token 사용법 REST API 호출 시, client에서 header에 JWT Token을 함께 전송함으로, REST API Server에서 client를 검증할 수 있다. REST API에서 client의 요청에 따라 1. Token 생성, 2. Token검증, 3. Token 정보 조회를 할 수 있는 기능을 추가해보자. REST API Server 프레임워크 : .NET Framework 4.5 1. REST API 프로젝트에 System.IdentityModel.Tokens.Jwt를 추가한다. Install-Package System.IdentityModel.Tokens.Jwt packages.config에서 설치 확인! 2. JWT 클래스 추가 REST API 프로젝트에 JWT폴더 추가, 하위에 clsJWT.c.. 2020. 10. 23. C#] AES128, AES256 암호화 복호화 코드 1. AES128 암호화, 복호화 코드 using System; using System.Collections.Generic; using System.Text; using System.Security.Cryptography; using System.IO; namespace COMMON.API { public static class HashHelper { #region Encrypt - AES128로 암호화 public static string EncryptByAES128IncludedPassword(string text) { string result = HashHelper.EncryptByAES128(text, "비밀번호"); return result; } public static string Encryp.. 2020. 10. 16. C#] 파일 업로드 시, MIME TYPE 체크, 확장자 필터링 1. 원하는 업로드 파일 개수와, 확장자가 정해져 있을 경우 아래 함수 호출하여 에러 메시지를 return 받을 수 있다. public string CheckValidFile(HttpFileCollectionBase files, int count, string fileTypes) { int fileCount = 0; string[] fileType = fileTypes.Split(',').ToArray(); foreach (string fileName in files) { foreach (string file in fileType) { HttpPostedFileBase fileBase = files[fileName]; if (fileBase.ContentLength == 0) continue; if (f.. 2020. 10. 15. C#] XSS(Cross-site Scripting) - 스크립트 필터링 크로스사이트 스크립팅 악의적인 사용자가 공격하려는 사이트에 스크립트를 넣는 기법 보안위협 웹 사이트 게시판, URL등에 악의적인 스크립트를 삽입하여 사용자의 쿠키(세션)를 도용하거나 악성코드(URL 리다이렉트)를 유포할 수 있다. 취약한 코드 사용자 입력 값에 대한 검증 및 필터링이 이루어지지 않으며, HTML코드가 입력실행되는 경우 조치방법 사용자로부터 입력받는 인수값에 대해서는 검증 로직을 추가하거나, 부득이하게 게시판에서 HTML을 사용하는 경우 HTML코드 중 필요한 코드에 대해서만 입력 가능하도록 설정 1. 검색어에서 XSS를 방지하기 위해, 특수기호 필터링 public String CleanInput(string strIn) { // Replace invalid characters with e.. 2020. 10. 6. C#] 개인정보 마스킹 : 이름, 주소, 휴대폰번호 1. 이름 마스킹 : 첫 글자 이상 마스킹 예 : 김*, 이** public static string SetMask(string str, int len) { // str을 len을 제외하고 나머지 마스킹 string result = string.Empty; if (string.IsNullOrEmpty(str) || str.Length x == lastChar) && !isMaskingOrder) { isMaskingOrder = true; result += addr + " "; } else { if (!isMaskingOrder) { result += addr + " "; } else { for (int i = 0; i < addr.Length; i++) { result = string.Concat(re.. 2020. 10. 6. 이전 1 ··· 9 10 11 12 다음 728x90 반응형