using System.Threading.Tasks;
using System.Collections.Generic;
public class BrightedgeViewModel
public string CurrentUrl { get; set; }
public string HashCalc { get; set; }
public BrightedgeSourceViewModel DataRetrivied { get; set; }
public class BrightedgeSourceViewModel
public List<BrightedgeNodeViewModel> Nodes { get; set; }
public class BrightedgeNodeViewModel
public string Feature_Group { get; set; }
public string Content { get; set; }
private readonly static string pageUrl = "https://ft1-cm-oap-us-us.wsf-e-loreal.com/makeup";
private readonly static string accountId = "f00000000092503";
private readonly static HttpClient client = new HttpClient();
private readonly static string serverUrl = "https://api.brightedge.com/api/ixf/1.0.0/get_capsule";
public static async Task Main(string[] args)
var currentRequestUrl = new Uri(pageUrl);
var uriBuilder = new UriBuilder
Scheme = currentRequestUrl.Scheme,
Host = currentRequestUrl.Host,
Path = currentRequestUrl.AbsolutePath
var uri = uriBuilder.ToString();
var result = GetInfo(uri);
Console.WriteLine("Response:");
Console.WriteLine(result);
var u = JsonConvert.DeserializeObject<BrightedgeSourceViewModel>(result);
public static String GetInfo(String pageUrl)
var hash = getPageHash(pageUrl);
var urlToRequest = String.Format("{0}/{1}/{2}", serverUrl, accountId, hash);
Console.WriteLine("HASH:" +hash);
Console.WriteLine("Current URL:" +pageUrl);
Console.WriteLine("URL Request:" +urlToRequest);
var response = client.GetAsync(urlToRequest).Result;
if (response.StatusCode == HttpStatusCode.OK)
return response.Content.ReadAsStringAsync().Result;
public static long getSignedNumber(long number)
long mask = (long)(Math.Pow(2, bitLength) - 1);
long testMask = 1L << (bitLength - 1);
if ((number & testMask) != 0) {
public static String getPageHash(String url)
char[] characterArray = url.ToCharArray(0, url.Length);
for (int i = 0; i < characterArray.Length; i++) {
int characterOrd = characterArray[i];
long temp1 = getSignedNumber(hash << 5);
long temp2 = getSignedNumber(temp1 - hash);
hash = getSignedNumber(temp2 + characterOrd);
hash = getSignedNumber(hash & hash);
return String.Format("0{0}", -hash);
return String.Format("{0}", hash);