2

The link here What is the best method for key validation? has an answer for JS, and an answer for calculating it yourself, of which I have can't understand because I don't have a deep CS background.

There's no such feature in https://github.com/QuantozTechnology/csharp-stellar-base or https://github.com/elucidsoft/dotnet-stellar-sdk.

1 Answer 1

1

Here is a simple method for elucidsoft SDK:

bool IsAccountIdValid(string accountId) {
    if (!String.IsNotNullOrEmpty(encoded) && encoded.Length != 56) return false;

    try {
        var decoded = StrKey.DecodeStellarAccountId(accountId);
        if (decoded.Length !== 32) return false;    
        return true;
    } catch {
        return false;
    }
}

If you want to check the validity of a secret key, just change DecodeStellarAccountId to DecodeStellarSecretSeed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.