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

Method DecryptString

cipher/rsa/rsa2.go:80–95  ·  view source on GitHub ↗

DecryptString decrypts the data using RSA algorithm returns the decrypted string

(data string)

Source from the content-addressed store, hash-verified

78// DecryptString decrypts the data using RSA algorithm
79// returns the decrypted string
80func (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
98func (rsa *rsa) GetPublicKey() (uint64, uint64) {

Callers 2

TestRSAFunction · 0.80
BenchmarkRSADecryptionFunction · 0.80

Calls 1

encryptDecryptIntFunction · 0.85

Tested by 2

TestRSAFunction · 0.64
BenchmarkRSADecryptionFunction · 0.64