public void StringConvertsToByteArrayCorrectly() { var allBytes = Enumerable.Range(0, 256).Select(n => (byte)n).ToArray(); var str = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; Assert.Equal(allBytes, ByteArrayExtensions.ParseHexString(str)); }
public void SyncGetByHashNotEmpty() { using var client = CreateClient(Configuration.LocalBaseUrl); var tx = client.Transactions.GetByHash( ByteArrayExtensions.ParseHexString(ExistingHash)); OutputHelper.WriteLine("Deserialized into"); Dump(tx); TxIsDelegateAndNotEmpty(tx); }
public BinaryPrivateKey ParsePrivateKey(string encodedKey, string?passphrase) { var(headers, encryptedBytes) = Unarmor(encodedKey); if (!string.Equals("bcrypt", headers.TryGetOrDefault("kdf"))) { throw new NotSupportedException($"Unrecognized armor type: {headers.TryGetOrDefault("kdf")}."); } var salt = ByteArrayExtensions.ParseHexString(headers.TryGetOrDefault("salt")); if (salt == null) { throw new ArgumentException("Key must contain hex encoded salt."); } var key = MakeKeyEncryptionKey(salt, passphrase ?? throw new ArgumentNullException(nameof(passphrase))); return(new BinaryPrivateKey(headers.TryGetOrDefault("type"), DecryptXsalsa20(encryptedBytes, key))); }
public static byte[] StdSignDocBytes() => ByteArrayExtensions.ParseHexString( "7b226163636f756e745f6e756d626572223a223133222c22636861696e5f6964223a22746573745f636861696e222c22666565223a7b22616d6f756e74223a5b5d2c22676173223a22313030303030227d2c226d656d6f223a22746573745f6d656d6f222c226d736773223a5b7b2274797065223a22636f736d6f732d73646b2f4d736753656e64222c2276616c7565223a7b22616d6f756e74223a5b7b22616d6f756e74223a223130222c2264656e6f6d223a22666f6f636f696e227d5d2c2266726f6d5f61646472657373223a22636f736d6f733171797071787071397163756866777978222c22746f5f61646472657373223a22636f736d6f733176346e7877357774366a37227d7d5d2c2273657175656e6365223a223137227d");
public override object?ReadJson(JsonReader reader, Type objectType, object?existingValue, JsonSerializer serializer) { var deserializedString = serializer.Deserialize <string>(reader); return(ByteArrayExtensions.ParseHexString(deserializedString)); }