DecryptString decrypts the data using RSA algorithm returns the decrypted string
(data string)
| 78 | // DecryptString decrypts the data using RSA algorithm |
| 79 | // returns the decrypted string |
| 80 | func (rsa *rsa) DecryptString(data string) string { |
| 81 | result := "" |
| 82 | middle := []byte(data) |
| 83 | |
| 84 | for i := 0; i < len(middle); i += 8 { |
| 85 | if i+8 > len(middle) { |
| 86 | break |
| 87 | } |
| 88 | |
| 89 | slice := middle[i : i+8] |
| 90 | num := binary.BigEndian.Uint64(slice) // convert byte slice to uint64 |
| 91 | result += fmt.Sprintf("%c", encryptDecryptInt(rsa.privateKey, rsa.modulus, num)) |
| 92 | } |
| 93 | |
| 94 | return result |
| 95 | } |
| 96 | |
| 97 | // GetPublicKey returns the public key and modulus |
| 98 | func (rsa *rsa) GetPublicKey() (uint64, uint64) { |