MCPcopy
hub / github.com/TheAlgorithms/Go / FuzzRsa

Function FuzzRsa

cipher/rsa/rsa_test.go:79–97  ·  view source on GitHub ↗
(f *testing.F)

Source from the content-addressed store, hash-verified

77}
78
79func FuzzRsa(f *testing.F) {
80 for _, rsaTestInput := range rsaTestData {
81 f.Add(rsaTestInput.input)
82 }
83 f.Fuzz(func(t *testing.T, input string) {
84 e, d, n := testPrecondition(t)
85 encrypted, err := Encrypt([]rune(input), e, n)
86 if err != nil {
87 t.Fatalf("failed to encrypt string: %v", err)
88 }
89 decrypted, err := Decrypt(encrypted, d, n)
90 if err != nil {
91 t.Fatalf("failed to decrypt string: %v", err)
92 }
93 if decrypted != input {
94 t.Fatalf("expected: %q, got: %q", input, decrypted)
95 }
96 })
97}

Callers

nothing calls this directly

Calls 4

testPreconditionFunction · 0.85
EncryptFunction · 0.70
DecryptFunction · 0.70
AddMethod · 0.65

Tested by

no test coverage detected