summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-09-09 14:57:55 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-09-09 14:57:55 +0200
commitb4a326d05d2aca748f3e36ff00b513ce3c2578f7 (patch)
tree70d3a72bf0c79eeb72450ed65c113ac894c9363e
parent98e85b6bd755791b8571843c95b443122760057e (diff)
Implement RSA in Ivy (APL)
-rw-r--r--rsa.ivy20
1 files changed, 20 insertions, 0 deletions
diff --git a/rsa.ivy b/rsa.ivy
new file mode 100644
index 0000000..433c801
--- /dev/null
+++ b/rsa.ivy
@@ -0,0 +1,20 @@
+op E public p = E, */p
+
+op E private p =
+ phi = */p-1
+ d = 1 take (1 == (E * iota phi) mod phi) sel iota phi
+ d, */p
+
+op C rsa Key = (C ** Key[1]) mod Key[2]
+
+P = 11 101
+pub = 3 public P
+priv = 3 private P
+
+msg = "test"
+pub
+priv
+
+ciphre = (code msg) rsa pub
+ciphre
+char ciphre rsa priv