在C#中加密对象 [英] Encrypt object in c#

查看:87
本文介绍了在C#中加密对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要加密对象.

我发现的所有示例都具有加密的字符串或文件.

All the example i found either they have encrypted string or file.

但是我需要加密对象并对其进行解码

But i need to encrypt object and decode it

我的对象将具有一些属性,例如

my object will have some properties like

公共类MyClass {

public class MyClass{

公用字符串Name {get; set;}

public string Name{get;set;}

公共字符串部门{get; set;}

public string Department{get;set;}

..................

..................

}

//控制器

公共ActionResult GetAllInfo(MyClass myClass){

public ActionResult GetAllInfo(MyClass myClass){

//现在我想加密myClass对象并对其进行解密

//Now i want to encrypt myClass object and decry-pt it

}

推荐答案

您打算如何使用此加密对象".

What do you intend to do with this 'encrypted object'.

因为对对象加密实际上对我来说没有多大意义.

Because encrypting an object doesn't really make much sense to me.

您可以加密对象中内保存的数据.

You can encrypt data held within the object.

或者您可以 序列化对象(将其转换为某种形式的字符串或二进制数据)以用于存储或通信目的,然后可以对其进行加密.在这种情况下-一旦序列化-只需使用您说的加密技术即可 已经找到.

Or you can serialize the object (converting it into some form of string or binary data) either for storage or communication purposes, which you can then encrypt. In this case - once serialized - it's just a matter of using the encryption techniques you say you have already found.


这篇关于在C#中加密对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆