Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 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.lib("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