CryptoSys PKI Pro Manual

Rsa.KeyMatch(String, String) Method

Verify that a pair of "internal" RSA private and public key strings are matched.

Syntax

[C#]
public static int KeyMatch(
   string privateKey,
   string publicKey 
)
[VB]
Public Shared Function KeyMatch (
   privateKey As String,
   publicKey As String 
) As Integer

Parameters

privateKey  String
Internal RSA private key string
publicKey  String
Internal RSA public key string

Return Value

Int32
0=valid key pair, or negative error code

Example

StringBuilder sbPublicKey = Rsa.ReadPublicKey(pubkeyFile);
StringBuilder sbPrivateKey = Rsa.ReadPrivateKey(prikeyFile, "password");
int n = Rsa.KeyMatch(sbPrivateKey.ToString(), sbPublicKey.ToString());
Console.WriteLine("Rsa.KeyMatch returns {0} (expecting 0)", n);
Debug.Assert(0 == n, "Rsa.KeyMatch failed.");

See Also

VB6/C equivalent: RSA_KeyMatch

[Contents] [Index]

[PREV: Rsa.KeyHashCode(StringBuilder) Method...]   [Contents]   [Index]   
   [NEXT: Rsa.KeyMatch(StringBuilder, StringBuilder) Method...]

Copyright © 2004-26 D.I. Management Services Pty Ltd t/a CryptoSys. All rights reserved. Generated 2026-09-21T05:59:39Z.