如何通过RC4算法加密/解密excel文件? [英] How to encrpy/decrypt excel file via RC4 algorithm?

查看:247
本文介绍了如何通过RC4算法加密/解密excel文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行以下代码并能够传递字符串值并获得所需的结果。但是我想通过数据传递excel文件的路径并使用数据加密excel文件的传递路径,然后通过RC4解密加密的excel文件的传递路径。



我试过的代码如下传递字符串值并获得所需的结果(加密/解密)。

public static string RC4(string input,string key){

StringBuilder result = new StringBuilder();

int x,y,j = 0;

int [] box = new int [256]; for(int i = 0; i< 256; i ++)

{box [i] = i;对于(int i = 0; i< 256; i ++){j =(key [i%key.Length] + box [i] + j)%256; $ b / b x = box [i]; box [i] = box [j]; box [j] = x; for(int i = 0; i< input.Length; i ++){y = i%256; j =(box [y] + j)%256; x = box [y]; box [y] = box [j]; box [j] = x; result.Append((char)(input [i] ^ box [(box [y] + box [j])%256]));返回result.ToString();}

I am doing following code and able to pass string values and get desired results. But I want to pass the path of the excel file with data and encrypt the passed path of the excel file with data and then decrypt the passed path of the encrypted excel file with data via RC4.

Code I tried is as follows to pass string values and get desired results(encrypt/decrypt).
public static string RC4(string input, string key){
StringBuilder result = new StringBuilder();
int x, y, j = 0;
int[] box = new int[256]; for (int i = 0; i < 256; i++)
{ box[i] = i; }
for (int i = 0; i < 256; i++) { j = (key[i % key.Length] + box[i] + j) % 256; x = box[i]; box[i] = box[j]; box[j] = x; } for (int i = 0; i < input.Length; i++) { y = i % 256; j = (box[y] + j) % 256; x = box[y]; box[y] = box[j]; box[j] = x; result.Append((char)(input[i] ^ box[(box[y] + box[j]) % 256])); } return result.ToString();}

推荐答案

这不是它的工作原理;你不能像过去那样来发布你的要求,并期望有人为你提供符合你需求的完整工作解决方案。



请阅读:

CodeProject Q& A FAQ [ ^ ]

你有什么尝试? [ ^ ]
This is not how it works here; you cannot come and post your requirements like you did, and expect someone to provide you with a full working solution that fits your needs.

Please read:
CodeProject Q&A FAQ[^]
What have you tried?[^]


这篇关于如何通过RC4算法加密/解密excel文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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