如何使用c#.net加密pdf文件? [英] How to encrypt the pdf file using c#.net?

查看:238
本文介绍了如何使用c#.net加密pdf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

我正在使用visual studio 2010并在Windows应用程序中工作。我需要加密现有的pdf文件,任何人都可以参考。



预付款。



问候,

Karthik M



我尝试过:



我试图加密现有的pdf文件。

解决方案

Microsoft 本身轻轻提供示例代码:加密数据 [ ^ ]。

如果您想对文件(任何文件)进行自定义加密,您需要执行以下操作:



1)打开二进制模式下的文件

2)读取数据(字符或块,适用于您的算法)

3)应用自定义加密算法数据

4)写入'新'文件。

5)重复3,4, 5直到整个文件被处理

6)关闭源文件和目标文件。



现在 - 可以进行许多改进,例如将整个原始文件保存在内存中,加密,然后覆盖源,但这取决于你想要做什么。还有预先编写的算法,如DES,可以为您完成大部分工作。


Dear all,
I am using visual studio 2010 and work in windows application. i need to encrypt the existing pdf files any one give me the reference for do it.

Thanks advance.

Regards,
Karthik M

What I have tried:

I am tried to encrypt the existing pdf file.

解决方案

Microsoft itself gently provides sample code: Encrypting Data[^].


If you wish to do a custom encryption of a file (any file), you need to do the following:

1) Open the file in binary mode
2) Read data (character or block, as appropriate for your algorithm)
3) Apply you custom encryption algorithm to data
4) Write to 'new' file.
5) Repeat 3, 4, 5 until entire file is processed
6) Close source and target files.

Now - there are many improvements that can be made, such as keeping the entire original file in memory, encrypting, and then overwriting the source, but that depends upon what you want to do. There are also pre-written algorithm, such as DES, to do much of the work for you.


这篇关于如何使用c#.net加密pdf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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