summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rsa.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/rsa.go b/lib/rsa.go
index 17cf6b0..00d575e 100644
--- a/lib/rsa.go
+++ b/lib/rsa.go
@@ -175,3 +175,14 @@ func RSAGenKey() (*RSAPair, error) {
return pair, nil
}
+
+func (r *RSAPub) Encrypt(msg []byte) []byte {
+ // Convert message to big int.
+ m := big.NewInt(0).SetBytes(msg)
+
+ // Encrypt.
+ c := big.NewInt(0).Exp(m, r.e, r.n)
+
+ return c.Bytes()
+}
+