diff --git a/CryptoExchange.Net/Authentication/ApiCredentials.cs b/CryptoExchange.Net/Authentication/ApiCredentials.cs index 1b1cbab..272ad93 100644 --- a/CryptoExchange.Net/Authentication/ApiCredentials.cs +++ b/CryptoExchange.Net/Authentication/ApiCredentials.cs @@ -48,13 +48,45 @@ namespace CryptoExchange.Net.Authentication } /// - /// Load a private key from a file path + /// Create API credentials using an API key and secret generated by the server /// - public async Task LoadPrivateKey(string path) + public static ApiCredentials HmacCredentials(string apiKey, string apiSecret, string? pass) { - using var filestream = File.OpenRead(path); - using var streamReader = new StreamReader(filestream); - return await streamReader.ReadToEndAsync().ConfigureAwait(false); + return new ApiCredentials(apiKey, apiSecret, pass, ApiCredentialsType.Hmac); + } + + /// + /// Create API credentials using an API key and an RSA private key in PEM format + /// + public static ApiCredentials RsaPemCredentials(string apiKey, string privateKey) + { + return new ApiCredentials(apiKey, privateKey, credentialType: ApiCredentialsType.RsaPem); + } + + /// + /// Create API credentials using an API key and an RSA private key in XML format + /// + public static ApiCredentials RsaXmlCredentials(string apiKey, string privateKey) + { + return new ApiCredentials(apiKey, privateKey, credentialType: ApiCredentialsType.RsaXml); + } + + /// + /// Create API credentials using an API key and an Ed25519 private key + /// + public static ApiCredentials Ed25519Credentials(string apiKey, string privateKey) + { + return new ApiCredentials(apiKey, privateKey, credentialType: ApiCredentialsType.Ed25519); + } + + /// + /// Load a key from a file + /// + public string ReadFromFile(string path) + { + using var fileStream = File.OpenRead(path); + using var streamReader = new StreamReader(fileStream); + return streamReader.ReadToEnd(); } ///