MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / EncryptString

Method EncryptString

cipher/rsa/rsa2.go:63–76  ·  view source on GitHub ↗

EncryptString encrypts the data using RSA algorithm returns the encrypted string

(data string)

Source from the content-addressed store, hash-verified

61// EncryptString encrypts the data using RSA algorithm
62// returns the encrypted string
63func (rsa *rsa) EncryptString(data string) string {
64 var nums []byte
65
66 for _, char := range data {
67 slice := make([]byte, 8)
68 binary.BigEndian.PutUint64( // convert uint64 to byte slice
69 slice,
70 encryptDecryptInt(rsa.publicKey, rsa.modulus, uint64(char)), // encrypt each character
71 )
72 nums = append(nums, slice...)
73 }
74
75 return string(nums)
76}
77
78// DecryptString decrypts the data using RSA algorithm
79// returns the decrypted string

Callers 3

TestRSAFunction · 0.80
BenchmarkRSAEncryptionFunction · 0.80
BenchmarkRSADecryptionFunction · 0.80

Calls 1

encryptDecryptIntFunction · 0.85

Tested by 3

TestRSAFunction · 0.64
BenchmarkRSAEncryptionFunction · 0.64
BenchmarkRSADecryptionFunction · 0.64