public void Keys_SameByteArray_AreEqual(ToxKeyType keyType, int keySize) { var key = new byte[keySize]; var key1 = new ToxKey(keyType, key); var key2 = new ToxKey(keyType, key); Assert.AreEqual(key1, key2); }
public void GetBytes_InputByteArray_AreNotSame(ToxKeyType keyType, int keySize) { var input = new byte[keySize]; var key = new ToxKey(keyType, input); var result = key.GetBytes(); Assert.AreNotSame(input, result); }
/// <summary> /// Initializes a new instance of the <see cref="ToxKey"/> class /// </summary> /// <param name="type"></param> /// <param name="key"></param> public ToxKey(ToxKeyType type, [NotNull] byte[] key) { if (key.Length != KeySize(type)) { throw new ArgumentException(nameof(key)); } this.KeyType = type; this.key = (byte[])key.Clone(); }
private static int KeySize(ToxKeyType type) { switch (type) { case ToxKeyType.Public: return(ToxConstants.PublicKeySize); case ToxKeyType.Secret: return(ToxConstants.SecretKeySize); } throw new NotImplementedException(); }
/// <summary> /// Initializes a new instance of the <see cref="ToxKey"/> class /// </summary> /// <param name="type"></param> /// <param name="key"></param> public ToxKey(ToxKeyType type, string key) { KeyType = type; _key = ToxTools.StringToHexBin(key); }
/// <summary> /// Initializes a new instance of the <see cref="ToxKey"/> class /// </summary> /// <param name="type"></param> /// <param name="key"></param> public ToxKey(ToxKeyType type, byte[] key) { KeyType = type; _key = key; }
/// <summary> /// Initializes a new instance of the <see cref="ToxKey"/> class /// </summary> /// <param name="type"></param> /// <param name="key"></param> public ToxKey(ToxKeyType type, string key) { KeyType = type; this.key = ToxTools.StringToHexBin(key); }
/// <summary> /// Initializes a new instance of the <see cref="ToxKey"/> class /// </summary> /// <param name="type"></param> /// <param name="key"></param> public ToxKey(ToxKeyType type, byte[] key) { KeyType = type; this.key = key; }
/// <summary> /// Initializes a new instance of the <see cref="ToxKey"/> class /// </summary> /// <param name="type"></param> /// <param name="key"></param> public ToxKey(ToxKeyType type, [NotNull] string key) : this(type, ToxTools.StringToHexBin(key)) { }