Blowfish algorithem通过c# [英] Blowfish algorithem through c#

查看:88
本文介绍了Blowfish algorithem通过c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在blowfish algorthim中有vc ++代码(这将用于开发编码和解密窗口)和

我有相同的c#代码

问题

例如我使用VC ++代码窗口加密一个字符串,如代码输出将来1D7C499AB79E32B6

和我使用c#window这里iam得到的输出是不同的d915ac54475662c54ca2e6bcb3ce7ddb



但是我的代码中我需要两个结果同样的问题。

i have vc++ code in blowfish algorthim(this will used to develop encription and decription window) and
iam having c# code in same
Problem
For example i used VC++ code window encrypt one string like "code" output will come "1D7C499AB79E32B6"
and same i used c# window here iam getting output is different "d915ac54475662c54ca2e6bcb3ce7ddb"

but i need both results same whats problem in my code.

推荐答案

查看此链接



http ://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesvbcs/thread/53340f6f-322a-4f47-a074-09cd347632d5/ [ ^ ]


显然要么1 < sup> st 算法的实现方式各不相同,或者2 nd 先决条件不同。



在第一种情况下除了使算法以完全相同的方式运行之外,没有什么可做的。

第二种情况很可能是由于字符串由不同的字节数表示。例如,编码字符串的C#变体是VC ++编码变体的两倍。这可能导致人们假设输入的大小(以字节为单位)是另一个(C#中的字符串是UTF而不是ASCII)。

通过尝试不同长度的更多字符串并比较结果编码的长度,可以加强这种情况。警告:编码后,相邻的一个长度增量不一定有不同的长度。这是因为这些算法通常在字节块上工作,并且如果由于缺少更多字符而无法填充块来编码填充将被添加。所以要做好准备,将会有长度为n,n + 1,n + 2,n + 3的源字符串序列,这些源字符串将产生长度为m的编码字符串,尽管内容不同。



问候,



- 曼弗雷德
Obviously either 1st the algorithms are implemented differently from one another or 2nd the prerequisites differ.

In the first case there''s nothing much to be done except making the algorithms operate exactly the same way.
The second is most likely due to the strings being represented by a different number of bytes. The C# variant of the encoded string for instance is twice as long as the VC++ encoded variant. This could lead one to assume that the input is twice as large (in bytes) as the other (Strings in C# are UTF and not ASCII).
The case can be strengthened by trying out further strings of differing length and comparing the length of the resulting encoding. Caveat: Adjacent increments of one in length don''t necessarily have different length after encoding. This is due to the fact that these algorithms often work on blocks of bytes and if a block can''t be filled for lack of more characters to encode a padding will be added. So be prepared that there will be sequences of source strings with lengths of n, n+1, n+2, n+3 that will all yield an encoded string of length m, albeit with different content.

Regards,

— Manfred


这篇关于Blowfish algorithem通过c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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