Exemplo n.º 1
0
        /// <summary>
        /// Checks whether or not the given Tox ID is valid.
        /// </summary>
        /// <param name="id">A (ToxConstant.AddressSize * 2) character long hexadecimal string, containing a Tox ID.</param>
        /// <returns>True if the ID is valid, false if the ID is invalid.</returns>
        public static bool IsValid(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(false);
            }

            byte[] bytes = null;

            try { bytes = ToxTools.StringToHexBin(id); }
            catch { return(false); }

            return(IsValid(bytes));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the ToxId class.
 /// </summary>
 /// <param name="id">A (ToxConstant.AddressSize * 2) character long hexadecimal string, containing a Tox ID.</param>
 public ToxId(string id)
     : this(ToxTools.StringToHexBin(id))
 {
 }
Exemplo n.º 3
0
 public override string ToString()
 {
     return(ToxTools.HexBinToString(_id));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new tox id with the specified public key and nospam.
 /// </summary>
 /// <param name="publicKey">Public key to create this Tox ID with.</param>
 /// <param name="nospam">Nospam value to create this Tox ID with.</param>
 public ToxId(string publicKey, int nospam)
     : this(ToxTools.StringToHexBin(publicKey), nospam)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Retrieves a string of the tox key.
 /// </summary>
 /// <returns></returns>
 public string GetString()
 {
     return(ToxTools.HexBinToString(_key));
 }
Exemplo n.º 6
0
 /// <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);
 }