/// <summary> /// Decodes the provided hash into numbers. /// </summary> /// <param name="hash">Hash string to decode.</param> /// <returns>Array of 64-bit integers.</returns> public static long[] DecodeHashIdLongs(this string hash, HashIdOptions options = default) { if (options.IsDefaultOrNull()) { options = new HashIdOptions(); } return(GetNumbersFrom(hash, options)); }
/// <summary> /// Encodes the provided numbers into a hash string. /// </summary> /// <param name="numbers">List of 64-bit integers.</param> /// <returns>Encoded hash string.</returns> public static string EncodeHashId(this IEnumerable <ulong> numbers, HashIdOptions options = default) { if (options.IsDefaultOrNull()) { options = new HashIdOptions(); } return(GenerateHashFrom(numbers.ToArray(), options)); }
/// <summary> /// Decodes the provided hash into numbers. /// </summary> /// <param name="hash">Hash string to decode.</param> /// <returns>Array of integers.</returns> /// <exception cref="T:System.OverflowException">If the decoded number overflows integer.</exception> public static int[] DecodeHashIdInts(this string hash, HashIdOptions options = default) { if (options.IsDefaultOrNull()) { options = new HashIdOptions(); } var x = GetNumbersFrom(hash, options: options); return(Array.ConvertAll(x, n => (int)n)); }
/// <summary> /// Encodes the provided numbers into a hash string. /// </summary> /// <param name="numbers">List of integers.</param> /// <returns>Encoded hash string.</returns> public static string EncodeHashId(this IEnumerable <int> numbers, HashIdOptions options = default) { if (options.IsDefaultOrNull()) { options = new HashIdOptions(); } var longs = numbers.Select(n => (long)n).ToArray(); return(GenerateHashFrom(longs, options)); }