Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/RSA-code/Visual-Basic-.NET/rsa-code.vb
Normal file
21
Task/RSA-code/Visual-Basic-.NET/rsa-code.vb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
Imports System
|
||||
Imports System.Numerics
|
||||
Imports System.Text
|
||||
|
||||
Module Module1
|
||||
Sub Main()
|
||||
Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357")
|
||||
Dim e As BigInteger = 65537
|
||||
Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685")
|
||||
Dim plainTextStr As String = "Hello, Rosetta!"
|
||||
Dim plainTextBA As Byte() = ASCIIEncoding.ASCII.GetBytes(plainTextStr)
|
||||
Dim pt As BigInteger = New BigInteger(plainTextBA)
|
||||
If pt > n Then Throw New Exception() ' Blocking not implemented
|
||||
Dim ct As BigInteger = BigInteger.ModPow(pt, e, n)
|
||||
Console.WriteLine(" Encoded: " & ct.ToString("X"))
|
||||
Dim dc As BigInteger = BigInteger.ModPow(ct, d, n)
|
||||
Console.WriteLine(" Decoded: " & dc.ToString("X"))
|
||||
Dim decoded As String = ASCIIEncoding.ASCII.GetString(dc.ToByteArray())
|
||||
Console.WriteLine("As ASCII: " & decoded)
|
||||
End Sub
|
||||
End Module
|
||||
Loading…
Add table
Add a link
Reference in a new issue