public static T AESEncrypt<T>(T obj) where T : class
{
if (obj == null)
{
return obj;
} var properties = typeof(T).GetProperties(); foreach (System.Reflection.PropertyInfo info in properties)
{
if (info.GetMethod.ReturnType.Name == typeof(string).Name)
{
if (obj.GetType().GetProperty(info.Name).GetValue(obj, null) != null)
{
string plaintext = obj.GetType().GetProperty(info.Name).GetValue(obj, null).ToString();
string ciphertext = PEIS_Interface_HN.Common.AESUtils.Encrypt_Hex(plaintext, "db6d159a3b341cc53373aab7f72ccb1896b88782", "");
obj.GetType().GetProperty(info.Name).SetValue(obj, ciphertext);
}
}
else if (info.PropertyType.IsGenericType)//info.GetMethod.ReturnType.Name == typeof(List<>).Name )
{
var list = obj.GetType().GetProperty(info.Name).GetValue(obj, null) as IList;
if (list != null)
{
foreach (var item in list)
{
var ps = item.GetType().GetProperties();
foreach (System.Reflection.PropertyInfo i in ps)
{ if (i.GetMethod.ReturnType.Name == typeof(string).Name)
{
if (item.GetType().GetProperty(i.Name).GetValue(item, null) != null)
{
string plaintext = item.GetType().GetProperty(i.Name).GetValue(item, null).ToString();
string ciphertext = PEIS_Interface_HN.Common.AESUtils.Encrypt_Hex(plaintext, "db6d159a3b341cc53373aab7f72ccb1896b88782", "");
item.GetType().GetProperty(i.Name).SetValue(item, ciphertext);
}
}
else if (i.PropertyType.IsClass&&!i.PropertyType.IsGenericType)
{
object propertyValue = i.GetValue(item);
if (propertyValue != null)
{ foreach (var it in propertyValue.GetType().GetProperties())
{
string plaintext = it.GetValue(propertyValue)==null ?string.Empty:it.GetValue(propertyValue).ToString();
string ciphertext = PEIS_Interface_HN.Common.AESUtils.Encrypt_Hex(plaintext, "db6d159a3b341cc53373aab7f72ccb1896b88782", "");
it.SetValue(propertyValue, ciphertext);
} }
}
else if (i.GetMethod.ReturnType.Name == typeof(List<>).Name)
{
var zlist = item.GetType().GetProperty(i.Name).GetValue(item, null) as IList;
if (zlist != null)
{
foreach (var it in zlist)
{
var p = it.GetType().GetProperties();
foreach (System.Reflection.PropertyInfo zi in p)
{ if (zi.GetMethod.ReturnType.Name == typeof(string).Name)
{
if (it.GetType().GetProperty(zi.Name).GetValue(it, null) != null)
{
string plaintext = it.GetType().GetProperty(zi.Name).GetValue(it, null).ToString();
string ciphertext = PEIS_Interface_HN.Common.AESUtils.Encrypt_Hex(plaintext, "db6d159a3b341cc53373aab7f72ccb1896b88782", "");
it.GetType().GetProperty(zi.Name).SetValue(it, ciphertext);
}
}
}
}
} } } } } } }
return obj;
}

最新文章

  1. 车牌号对应归属地及城市JSON带简码
  2. Qt拖拽界面 (*.ui) 缩放问题及解决办法(在最顶层放一个Layout)
  3. 函数xdes_init
  4. OpenJudge/Poj 1191 棋盘分割
  5. QT 自定义assert
  6. Spring MVC 中的 forward 和 redirect
  7. Android 点击事件,4种回调。
  8. 关于jsp中超链接的相对路径
  9. 机器学习实战__安装python环境
  10. 图片输出onerror事件
  11. adb调试实用命令
  12. java web每天定时执行任务(四步轻松搞定)
  13. RxSwift 系列(三) -- Combination Operators
  14. Java多线程:wait(),notify(),notifyAll()
  15. C# 跳转新的标签页
  16. 题解-洛谷P1303 A*B Problem(高精)
  17. metasploit 教程之信息收集
  18. CCF CSP 201509-1 数列分段
  19. Android破解学习之路(十六)—— dll破解的IL指令
  20. ACM-ICPC 2017 Asia Xi&#39;an A XOR (线性基+线段树思想)

热门文章

  1. Linux学习环境搭建流程
  2. 微信小程序canvas 证件照制作
  3. [C++] - GCC和LLVM对方法 warning: non-void function does not return a value [-Wreturn-type] 的处理差异
  4. Java安全之Mojarra JSF反序列化
  5. lambda、map、reduce、filter、sorted函数
  6. 学习ASP.NET Core Blazor编程系列十——路由(下)
  7. vue项目中,alert使用
  8. 云小课|云小课教您如何选择Redis实例类型
  9. TabControl控件的简单使用-添加tab
  10. ATM购物车项目总结