Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/RSA-code/11l/rsa-code.11l
Normal file
23
Task/RSA-code/11l/rsa-code.11l
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
V n = BigInt(‘9516311845790656153499716760847001433441357’)
|
||||
V e = BigInt(65537)
|
||||
V d = BigInt(‘5617843187844953170308463622230283376298685’)
|
||||
|
||||
V txt = ‘Rosetta Code’
|
||||
|
||||
print(‘Plain text: ’txt)
|
||||
|
||||
V txtN = txt.reduce(BigInt(0), (a, b) -> a * 256 + b.code)
|
||||
print(‘Plain text as a number: ’txtN)
|
||||
|
||||
V enc = pow(txtN, e, n)
|
||||
print(‘Encoded: ’enc)
|
||||
|
||||
V dec = pow(enc, d, n)
|
||||
print(‘Decoded: ’dec)
|
||||
|
||||
V decTxt = ‘’
|
||||
L dec != 0
|
||||
decTxt ‘’= Char(code' dec % 256)
|
||||
dec I/= 256
|
||||
|
||||
print(‘Decoded number as text: ’reversed(decTxt))
|
||||
Loading…
Add table
Add a link
Reference in a new issue