diff options
author | siddharth ravikumar <s@ricketyspace.net> | 2022-08-14 13:54:05 -0400 |
---|---|---|
committer | siddharth ravikumar <s@ricketyspace.net> | 2022-08-14 13:54:05 -0400 |
commit | eee7a6af613b7d4c7cb4b8333d1f5ecf30236301 (patch) | |
tree | b62380be7024c31c46da5d45a83f88b12ad35d9b /lib | |
parent | 3aadff0d4782858afb687593ba54a6066467c95d (diff) |
lib: RSAPub: add `Encrypt`
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rsa.go | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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() +} + |