欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

vb.netrsa的簡單介紹

如何用VB實(shí)現(xiàn)RSA加密算法,網(wǎng)上找到了一份代碼,沒有注釋看不懂,請大神解釋!!!

RSA算法非常簡單,概述如下:

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了曲水免費(fèi)建站歡迎大家使用!

找兩素?cái)?shù)p和q

取n=p*q

取t=(p-1)*(q-1)

取任何一個數(shù)e,要求滿足et并且e與t互素(就是最大公因數(shù)為1)

取d*e%t==1

這樣最終得到三個數(shù): n d e

設(shè)消息為數(shù)M (M n)

設(shè)c=(M**d)%n就得到了加密后的消息c

設(shè)m=(c**e)%n則 m == M,從而完成對c的解密。

注:**表示次方,上面兩式中的d和e可以互換。

在對稱加密中:

n d兩個數(shù)構(gòu)成公鑰,可以告訴別人;

n e兩個數(shù)構(gòu)成私鑰,e自己保留,不讓任何人知道。

給別人發(fā)送的信息使用e加密,只要別人能用d解開就證明信息是由你發(fā)送的,構(gòu)成了簽名機(jī)制。

別人給你發(fā)送信息時使用d加密,這樣只有擁有e的你能夠?qū)ζ浣饷堋?/p>

rsa的安全性在于對于一個大數(shù)n,沒有有效的方法能夠?qū)⑵浞纸?/p>

從而在已知n d的情況下無法獲得e;同樣在已知n e的情況下無法

求得d。

二實(shí)踐

接下來我們來一個實(shí)踐,看看實(shí)際的操作:

找兩個素?cái)?shù):

p=47

q=59

這樣

n=p*q=2773

t=(p-1)*(q-1)=2668

取e=63,滿足et并且e和t互素

用perl簡單窮舉可以獲得滿主 e*d%t ==1的數(shù)d:

C:\Tempperl -e "foreach $i (1..9999){ print($i),last if $i*63%2668==1 }"

847

即d=847

最終我們獲得關(guān)鍵的

n=2773

d=847

e=63

取消息M=244我們看看

加密:

c=M**d%n = 244**847%2773

用perl的大數(shù)計(jì)算來算一下:

C:\Tempperl -Mbigint -e "print 244**847%2773"

465

即用d對M加密后獲得加密信息c=465

解密:

我們可以用e來對加密后的c進(jìn)行解密,還原M:

m=c**e%n=465**63%2773 :

C:\Tempperl -Mbigint -e "print 465**63%2773"

244

即用e對c解密后獲得m=244 , 該值和原始信息M相等。

三字符串加密

把上面的過程集成一下我們就能實(shí)現(xiàn)一個對字符串加密解密的示例了。

每次取字符串中的一個字符的ascii值作為M進(jìn)行計(jì)算,其輸出為加密后16進(jìn)制

的數(shù)的字符串形式,按3字節(jié)表示,如01F

代碼如下:

#!/usr/bin/perl -w

#RSA 計(jì)算過程學(xué)習(xí)程序編寫的測試程序

#watercloud 2003-8-12

#

use strict;

use Math::BigInt;

my %RSA_CORE = (n=2773,e=63,d=847); #p=47,q=59

my $N=new Math::BigInt($RSA_CORE{n});

my $E=new Math::BigInt($RSA_CORE{e});

my $D=new Math::BigInt($RSA_COREdzlbvzv);

print "N=$N D=$D E=$E\n";

sub RSA_ENCRYPT

{

my $r_mess = shift @_;

my ($c,$i,$M,$C,$cmess);

for($i=0;$i length($$r_mess);$i++)

{

$c=ord(substr($$r_mess,$i,1));

$M=Math::BigInt-new($c);

$C=$M-copy(); $C-bmodpow($D,$N);

$c=sprintf "%03X",$C;

$cmess.=$c;

}

return \$cmess;

}

sub RSA_DECRYPT

{

my $r_mess = shift @_;

my ($c,$i,$M,$C,$dmess);

for($i=0;$i length($$r_mess);$i+=3)

{

$c=substr($$r_mess,$i,3);

$c=hex($c);

$M=Math::BigInt-new($c);

$C=$M-copy(); $C-bmodpow($E,$N);

$c=chr($C);

$dmess.=$c;

}

return \$dmess;

}

my $mess="RSA 娃哈哈哈~~~";

$mess=$ARGV[0] if @ARGV = 1;

print "原始串:",$mess,"\n";

my $r_cmess = RSA_ENCRYPT(\$mess);

print "加密串:",$$r_cmess,"\n";

my $r_dmess = RSA_DECRYPT($r_cmess);

print "解密串:",$$r_dmess,"\n";

#EOF

測試一下:

C:\Tempperl rsa-test.pl

N=2773 D=847 E=63

原始串:RSA 娃哈哈哈~~~

加密串:5CB6CD6BC58A7709470AA74A0AA74A0AA74A6C70A46C70A46C70A4

解密串:RSA 娃哈哈哈~~~

C:\Tempperl rsa-test.pl 安全焦點(diǎn)(xfocus)

N=2773 D=847 E=63

原始串:安全焦點(diǎn)(xfocus)

加密串:3393EC12F0A466E0AA9510D025D7BA0712DC3379F47D51C325D67B

解密串:安全焦點(diǎn)(xfocus)

vb.net中實(shí)現(xiàn)rsa加密解密 急!急!

我覺得你的并不是RSA加密解密算法。

在.net的有一個System.Security.Cryptography的命名空間,里面有一RSACryptoServiceProvider的類用來對byte進(jìn)行RSA加密解密。

具體例子如下:

using System;

using System.Security.Cryptography;

using System.Text;

class RSACSPSample

{

static void Main()

{

try

{

//Create a UnicodeEncoder to convert between byte array and string.

UnicodeEncoding ByteConverter = new UnicodeEncoding();

//Create byte arrays to hold original, encrypted, and decrypted data.

byte[] dataToEncrypt = ByteConverter.GetBytes("Data to Encrypt");

byte[] encryptedData;

byte[] decryptedData;

//Create a new instance of RSACryptoServiceProvider to generate

//public and private key data.

RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();

//Pass the data to ENCRYPT, the public key information

//(using RSACryptoServiceProvider.ExportParameters(false),

//and a boolean flag specifying no OAEP padding.

encryptedData = RSAEncrypt(dataToEncrypt,RSA.ExportParameters(false), false);

//Pass the data to DECRYPT, the private key information

//(using RSACryptoServiceProvider.ExportParameters(true),

//and a boolean flag specifying no OAEP padding.

decryptedData = RSADecrypt(encryptedData,RSA.ExportParameters(true), false);

//Display the decrypted plaintext to the console.

Console.WriteLine("Decrypted plaintext: {0}", ByteConverter.GetString(decryptedData));

}

catch(ArgumentNullException)

{

//Catch this exception in case the encryption did

//not succeed.

Console.WriteLine("Encryption failed.");

}

}

static public byte[] RSAEncrypt(byte[] DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding)

{

try

{

//Create a new instance of RSACryptoServiceProvider.

RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();

//Import the RSA Key information. This only needs

//toinclude the public key information.

RSA.ImportParameters(RSAKeyInfo);

//Encrypt the passed byte array and specify OAEP padding.

//OAEP padding is only available on Microsoft Windows XP or

//later.

return RSA.Encrypt(DataToEncrypt, DoOAEPPadding);

}

//Catch and display a CryptographicException

//to the console.

catch(CryptographicException e)

{

Console.WriteLine(e.Message);

return null;

}

}

static public byte[] RSADecrypt(byte[] DataToDecrypt, RSAParameters RSAKeyInfo,bool DoOAEPPadding)

{

try

{

//Create a new instance of RSACryptoServiceProvider.

RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();

//Import the RSA Key information. This needs

//to include the private key information.

RSA.ImportParameters(RSAKeyInfo);

//Decrypt the passed byte array and specify OAEP padding.

//OAEP padding is only available on Microsoft Windows XP or

//later.

return RSA.Decrypt(DataToDecrypt, DoOAEPPadding);

}

//Catch and display a CryptographicException

//to the console.

catch(CryptographicException e)

{

Console.WriteLine(e.ToString());

return null;

}

}

}

[Visual Basic]

Try

'Create a new RSACryptoServiceProvider object.

Dim RSA As New RSACryptoServiceProvider()

'Export the key information to an RSAParameters object.

'Pass false to export the public key information or pass

'true to export public and private key information.

Dim RSAParams As RSAParameters = RSA.ExportParameters(False)

Catch e As CryptographicException

'Catch this exception in case the encryption did

'not succeed.

Console.WriteLine(e.Message)

End Try

[C#]

try

{

//Create a new RSACryptoServiceProvider object.

RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();

//Export the key information to an RSAParameters object.

//Pass false to export the public key information or pass

//true to export public and private key information.

RSAParameters RSAParams = RSA.ExportParameters(false);

}

catch(CryptographicException e)

{

//Catch this exception in case the encryption did

//not succeed.

Console.WriteLine(e.Message);

}

.net軟件加密,加密鎖哪種比較好,混淆代碼可以實(shí)現(xiàn)嗎?

加密鎖:威步(WIBU)的CodeMeter,AxProtector(for.net)兩款軟件加密鎖性能非常不錯 混淆的問題,與傳統(tǒng)的代碼混淆工具(Obfuscator)不同,AxProtector可以完全阻止對.NET 程序集(由 C#, VB.NET, Delphi.NET, ASP.Net… 等語言編寫)的反編譯。通俗的講,AxProtector在破解者和您的 .NET 代碼之間構(gòu)建了強(qiáng)大的防破解保護(hù)屏障,生成一個基于 Windows 的而不是基于 MSIL 的兼容格式文件。原始的 .NET 代碼完整的被加密后封裝在本地代碼內(nèi),無論何時都不會釋放到硬盤,對于破解者是不可見的。 與單純的.net加密軟件不同,AxProtector與CodeMeter硬件加密狗配套餐使用,采用了更為嚴(yán)密的密鑰管理,及最先進(jìn)的AES、RSA、ECC等加密算法存儲或傳輸密鑰,保證通訊安全。 .Net代碼編譯后生成的 .class 中包含有源代碼中的所有信息(不包括注釋),尤其是在其中保存有調(diào)試信息的時候。所以一個按照正常方式編譯的.class 文件可以非常輕易地被反編譯。一般軟件開發(fā)商會采用一種叫做混淆器的工具。混淆器的作用是對編譯好的代碼進(jìn)行混淆,使得其無法被反編譯或者反編譯后的代碼混亂難懂。由于混淆器只是混淆了方法名稱或流程,而不能防止源代碼被反編譯,因此混淆器的作用只是增加了反編譯的難度,最終的結(jié)果也是治標(biāo)不治本。對于一些掌握工具的人來說幾乎還是透明的。AxProtector是一款真正意義的加密源代碼、防止反編譯的.net軟件加密軟件。 AxProtector加密了.net原代碼,任何時候原代碼都不可能被還原到硬盤當(dāng)中。采用AxProtector加密后的.net代碼只有在程序調(diào)用或執(zhí)行某一段函數(shù)的時候,才能通過AxProtectorClass在內(nèi)存中解密后返回到程序中執(zhí)行,運(yùn)行之后迅速立即加密。這種隨機(jī)加密、按需解密原代碼的功能,能很好的防止.Net程序的反編譯,同時能夠很好地防止API加密點(diǎn)被摘除。有效地保證了源代碼的執(zhí)行效率和安全性。

新聞名稱:vb.netrsa的簡單介紹
文章位置:http://chinadenli.net/article36/dsgsspg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣Google關(guān)鍵詞優(yōu)化網(wǎng)站建設(shè)定制網(wǎng)站微信小程序

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計(jì)