/// <summary> /// Takes a Guid and provides a relatively unique hashed value. /// </summary> /// <param name="UniqueID">The Guid to hash</param> /// <returns>A hashed String of the Guid.</returns> public static string Hash(this Guid UniqueID) { using (System.Security.Cryptography.MACTripleDES des = new MACTripleDES()) { return Base36.NumberToBase36(Convert.ToInt64(System.BitConverter.ToString(des.ComputeHash(UniqueID.ToByteArray())).Replace("-", ""), 16)).Replace("-", "0"); } }
/// <summary> /// Returns a string representation padding the leading edge with /// zeros if necessary to make up the number of characters /// </summary> /// <param name="minimumDigits">The minimum number of digits that the string must contain</param> /// <returns>The padded string representation</returns> public string ToString(int minimumDigits) { string base36Value = Base36.NumberToBase36(numericValue); if (base36Value.Length >= minimumDigits) { return(base36Value); } else { string padding = new string('0', (minimumDigits - base36Value.Length)); return(string.Format("{0}{1}", padding, base36Value)); } }
/// <summary> /// Returns a string representation of the Base36 number /// </summary> /// <returns>A string representation</returns> public override string ToString() { return(Base36.NumberToBase36(numericValue)); }