public static async Task <CryptoPriceResult[]> GetCryptosAsync(this CryptoPriceService crypto, Int32 limit = 100) { var request = new CryptoRequest { RelativeUrl = "/v2/ticker", Properties = new Dictionary <String, String> { ["limit"] = limit.ToString() } }; var response = await crypto.SendAsync <CryptoPriceResult[]>(request); return(response.Result); }
public byte[] DecryptWithPrivate(CryptoRequest cryptoRequest) { var bytes64 = cryptoRequest.Data64; var privateKey = cryptoRequest.Password; byte[] bytes = Convert.FromBase64String(bytes64); Chilkat.Rsa rsaEncryptor = new Chilkat.Rsa { EncodingMode = "hex" }; rsaEncryptor.ImportPrivateKey(privateKey); return(rsaEncryptor.DecryptBytes(bytes, usePrivateKey: true)); }
public string Operation(CryptoRequest req, bool isDecryption) { Chilkat.Crypt2 crypt = new Chilkat.Crypt2 { CryptAlgorithm = "aes", CipherMode = "cbc", KeyLength = 256, PaddingScheme = 0, EncodingMode = "hex" }; var data = Convert.FromBase64String(req.Data64); crypt.SetSecretKeyViaPassword(req.Password); var operated = isDecryption ? crypt.DecryptBytes(data) : crypt.EncryptBytes(data); return(Convert.ToBase64String(operated)); }
public string Decrypt(CryptoRequest req) => Operation(req, true);
public string Encrypt(CryptoRequest req) => Operation(req, false);