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

Function Decrypt

cipher/rsa/rsa.go:45–56  ·  view source on GitHub ↗

Decrypt decrypts encrypted rune slice based on the RSA algorithm

(encrypted []rune, privateExponent, modulus int64)

Source from the content-addressed store, hash-verified

43
44// Decrypt decrypts encrypted rune slice based on the RSA algorithm
45func Decrypt(encrypted []rune, privateExponent, modulus int64) (string, error) {
46 var decrypted []rune
47
48 for _, letter := range encrypted {
49 decryptedLetter, err := modular.Exponentiation(int64(letter), privateExponent, modulus)
50 if err != nil {
51 return "", ErrorFailedToDecrypt
52 }
53 decrypted = append(decrypted, rune(decryptedLetter))
54 }
55 return string(decrypted), nil
56}

Callers 2

TestEncryptDecryptFunction · 0.70
FuzzRsaFunction · 0.70

Calls 1

ExponentiationFunction · 0.92

Tested by 2

TestEncryptDecryptFunction · 0.56
FuzzRsaFunction · 0.56