public MemberItems DecryptResult(MemberItems result) { result.GetType().GetProperties().ToList().ForEach(p => { if (p.Name == "IteamUpdateAdminID" || p.Name == "IteamCreateAdminID" || p.Name == "Id" || p.Name == "Version" || p.Name == "Deleted" || p.Name == "CreatedAt" || p.Name == "UpdatedAt" || p.Name == "HideYN" || p.Name == "DeleteYN") // 복호화 안하고 통과 시킬 녀석들 { // 추가 처리 } else { //Debug.WriteLine((p.GetValue(result, null) ?? "").ToString()); p.SetValue(result, Crypto.AES_decrypt((p.GetValue(result, null) ?? "").ToString(), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV), null); //Debug.WriteLine((p.GetValue(result, null) ?? "").ToString()); } }); return result; }
public MemberItems EncryptResult(MemberItems result) { result.GetType().GetProperties().ToList().ForEach(p => { // Edit이나 Create의 경우는 필드를 체크할 필요 없음. - EF의 특성임. // Edit에서 암호화 시작 if (p.Name == "IteamUpdateAdminID" || p.Name == "IteamCreateAdminID" || p.Name == "Id" || p.Name == "Version" || p.Name == "Deleted" || p.Name == "CreatedAt" || p.Name == "UpdatedAt" || p.Name == "HideYN" || p.Name == "DeleteYN") // 현재 암호화 안하고 통과 시킬 녀석들 { // 추가 처리 } else { // edit을 저장하려 할 경우 EF에서 빈문자열의 경우 null이 들어오고 처리 되지 않는다. // view에서 annotation? // EF의 특성 // string이 아닌 datetimeoffset 등에서도 오류가 발생한다. int도 발생하겠지. // reflection 쓰지 말까... Debug.WriteLine(p.PropertyType.FullName); Debug.WriteLine((p.GetValue(result, null) ?? "").ToString()); p.SetValue(result, Crypto.AES_encrypt((p.GetValue(result, null) ?? "").ToString(), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV), null); // null인 경우 오류 가능성. 빈문자열로 치환해 암호화 한다. } }); return result; }