September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
16
Task/RSA-code/Zkl/rsa-code.zkl
Normal file
16
Task/RSA-code/Zkl/rsa-code.zkl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
var BN=Import("zklBigNum");
|
||||
|
||||
n:=BN("9516311845790656153499716760847001433441357");
|
||||
e:=BN("65537");
|
||||
d:=BN("5617843187844953170308463622230283376298685");
|
||||
|
||||
const plaintext="Rossetta Code";
|
||||
pt:=BN(Data(Int,0,plaintext)); // convert string (as stream of bytes) to big int
|
||||
if(pt>n) throw(Exception.ValueError("Message is too large"));
|
||||
|
||||
println("Plain text: ",plaintext);
|
||||
println("As Int: ",pt);
|
||||
ct:=pt.powm(e,n); println("Encoded: ",ct);
|
||||
pt =ct.powm(d,n); println("Decoded: ",pt);
|
||||
txt:=pt.toData().text; // convert big int to bytes, treat as string
|
||||
println("As String: ",txt);
|
||||
Loading…
Add table
Add a link
Reference in a new issue