EncryptString encrypts the data using RSA algorithm returns the encrypted string
(data string)
| 61 | // EncryptString encrypts the data using RSA algorithm |
| 62 | // returns the encrypted string |
| 63 | func (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 |