Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/RSA-code/PowerShell/rsa-code.psh
Normal file
13
Task/RSA-code/PowerShell/rsa-code.psh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
$n = [BigInt]::Parse("9516311845790656153499716760847001433441357")
|
||||
$e = [BigInt]::new(65537)
|
||||
$d = [BigInt]::Parse("5617843187844953170308463622230283376298685")
|
||||
$plaintextstring = "Hello, Rosetta!"
|
||||
$plaintext = [Text.ASCIIEncoding]::ASCII.GetBytes($plaintextstring)
|
||||
[BigInt]$pt = [BigInt]::new($plaintext)
|
||||
if ($n -lt $pt) {throw "`$n = $n < $pt = `$pt"}
|
||||
$ct = [BigInt]::ModPow($pt, $e, $n)
|
||||
"Encoded: $ct"
|
||||
$dc = [BigInt]::ModPow($ct, $d, $n)
|
||||
"Decoded: $dc"
|
||||
$decoded = [Text.ASCIIEncoding]::ASCII.GetString($dc.ToByteArray())
|
||||
"As ASCII: $decoded"
|
||||
Loading…
Add table
Add a link
Reference in a new issue