FreeSql icon indicating copy to clipboard operation
FreeSql copied to clipboard

数据加解密

Open Huahuz opened this issue 3 years ago • 2 comments

Feature 特性

通过 Attribute特性来标记指定字段,FreeSql 根据该标记对该字段加密存储和读取。

简要描述原因

敏感数据,如人员的工资等数据要求不能被dba和能直接访问到数据库的人员直接查看到值

使用场景

公司的系统加密存储敏感数据

Huahuz avatar Aug 17 '21 10:08 Huahuz

如果是字符串加密可以使用aop,希望可以对数字,时间等别的类型加密存储

Huahuz avatar Aug 17 '21 10:08 Huahuz

这是Guid空自动new的的aop:, 你试试自己改一下成你需要的版本

            fsql.Aop.AuditValue += new EventHandler<FreeSql.Aop.AuditValueEventArgs>((s, e) =>
            {
                if (e.Column.CsType == typeof(Guid) &&
                    e.Column.Attribute.MapType == typeof(string) &&
                    e.Value?.ToString() == Guid.Empty.ToString())
                    e.Value = FreeUtil.NewMongodbId();
            });

densen2014 avatar Sep 08 '21 12:09 densen2014