关于如何避免溢出的问题 [英] A question about how to avoid getting an overflow

查看:51
本文介绍了关于如何避免溢出的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..我有一个问题..我的老师给了我一个使用RSA加密文件的任务..我非常了解系统..我将文件转换为byte [] ..当我进行加密时,我得到的值大于类型字节允许的值,程序停止。有什么办法可以避免吗?



Hi.. I have a question.. My teacher gave me an assignment to encrypt files using RSA.. I understand the system very well.. I converted the file to byte[].. And when I do the encryption, I get values larger than the values permitted for the type byte and the program stops.. Is there any way to avoid that?

Sub encrypt()
    For i = 0 To bytes.Length - 1
        bytes(i) = fast(bytes(i), ee)
    Next
End Sub













Function fast(ByVal aa As Object, ByVal zz As Integer) As Integer
    Dim xx As Integer
    xx = 1
    While zz <> 0
        While zz Mod 2 = 0
            zz = zz \ 2
            aa = (aa * aa) Mod n
        End While
        zz = zz - 1
        xx = (xx * aa) Mod n
    End While
    Return xx
End Function





快速功能结束后停止..意味着它返回结果值...



It stops after the fast function ends.. Means after it returns the resulted value...

推荐答案

你不可能得到大于byt的值e,如果你正确地进行加密。现在,如果您创建了一个字节数组来保存生成的加密数据,那么您可能会遇到某种类型的数据溢出。



如果没有看到您的代码,它就会'不可能告诉你你做错了什么。
You can''t possibly get values larger than byte if you were doing the encryption properly. Now, if you created an array of bytes to hold the resulting encrypted data, THEN you might get some kind of array overflow.

Without seeing your code, it''s impossible to tell you what you did wrong.


你好,



请查看这篇文章:



RSA私钥加密 [ ^ ]

C#.NET中的公钥RSA加密 [ ^ ]

使用RSA Public共享Web Hosti中的密钥加密ng环境 [ ^ ]



这可能会有所帮助。



干杯,

JAFC
Hi,

Please, view this articles:

RSA Private Key Encryption[^]
Public Key RSA Encryption in C# .NET[^]
Using RSA Public Key Encryption in a Shared Web Hosting Environment[^]

It might help.

Cheers,
JAFC


这篇关于关于如何避免溢出的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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