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);
        }
示例#2
0
        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));
        }
示例#3
0
        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));
        }
示例#4
0
 public string Decrypt(CryptoRequest req) => Operation(req, true);
示例#5
0
 public string Encrypt(CryptoRequest req) => Operation(req, false);