/// <summary> /// Used for creating small readable crypto-tokens /// </summary> /// <param name="minimumLength"></param> /// <param name="tokenHashAlphabet"></param> /// <returns></returns> public static string CreateEncodedHashId(int minimumLength, string tokenHashAlphabet) { var seed = new Random(BitConverter.ToInt32(CreateRandomBytes(4), 0)).Next(0, int.MaxValue); var salt = CreateRandomBytes(32); string saltString = Convert.ToBase64String(salt); var hashId = new HashidsNet.Hashids(salt: saltString, minHashLength: minimumLength, alphabet: tokenHashAlphabet); var hash = hashId.Encode(seed); return(hash); }
public string Encrypt(int id) { return(_hash.Encode(id)); }
public void RoundtripInts() { var encodedValue = _hashids.Encode(_ints); var decodedValue = _hashids.Decode(encodedValue); }
public string GenerateHash(int urlId) { return(_hashIds.Encode(urlId)); }