1
해독 내가 필드를 차단PostSharp 필드를 차단 암호화하고 PostSharp를 사용
에 암호화/암호 해독을하고 싶은 나는 클래스
public class guestbookentry
{
[Encryption] // This Attribute has to Encrypt and Decrypt
public string Message { get; set; }
public string GuestName { get; set; }
}
나는 푸른 테이블에서 객체를 저장하고 있습니다에게 있습니다. 특정 필드 만 En/Decrypt를 가져와야합니다. 이 필드를 차단
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PostSharp;
using PostSharp.Aspects;
using EncryptionDecryption;
using PostSharp.Serialization;
using PostSharp.Aspects.Advices;
using PostSharp.Extensibility;
namespace GuestBook_Data
{
[Serializable]
public class EncryptionAttribute : LocationInterceptionAspect
{
[MulticastPointcut(Targets = MulticastTargets.Field, Attributes = MulticastAttributes.Instance)]
public override void OnSetValue(LocationInterceptionArgs args)
{
base.OnSetValue(args);
if (args.Value != null)
{
MD5CryptoServiceExample objMD5Encrypt = new MD5CryptoServiceExample();
args.Value = objMD5Encrypt.Encrypt(args.Value.ToString()).Replace(" ", "+");
args.ProceedSetValue();
}
}
public override void OnGetValue(LocationInterceptionArgs args)
{
base.OnGetValue(args);
if (args.Value != null)
{
MD5CryptoServiceExample objMD5Encrypt = new MD5CryptoServiceExample();
args.Value = objMD5Encrypt.Decrypt(args.Value.ToString()); //objMD5Encrypt.Decrypt(args.Value.ToString());
args.ProceedGetValue();
}
}
}
}
문제에
PostSharp 속성은 1. 연속 암호화하고 암호 해독 처리하기 곤란한 발생합니다.
친절base.OnSetValue(args)
를 호출하면
args.ProceedSetValue()
를 호출하고,
base.OnGetValue(args)
를 호출 한 것과 같은 상태가된다
args.ProceedGetValue()
를 호출하는 것과 동일하다는 것을,