public static string CreateToken(string IPAddress, string Token, long ticks) { string hashLeft = string.Empty; string hashRight = string.Empty; string encry1 = string.Empty; string encry2 = string.Empty; try { string key = Convert.ToString(ConfigurationManager.AppSettings["keyValue"]); string IV = Convert.ToString(ConfigurationManager.AppSettings["IVValue"]); string UniqueID = Convert.ToString(ConfigurationManager.AppSettings["UniqueID"]); // [encry1] CLientIDToken : IPAddress : ticks encry1 = string.Join(":", new string[] { Token, IPAddress, ticks.ToString() }); // [encry2] UniqueID + ticks hashLeft = Convert.ToBase64String(TripleDESAlgorithm.Encryption(encry1, key, IV)); hashRight = string.Join(":", new string[] { UniqueID, ticks.ToString() }); // [CLientIDToken : IPAddress : ticks + UniqueID + ticks] var basestring = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Join(":", hashRight, hashLeft))); return(basestring); } catch (Exception) { throw; } }
public static string GetAPIKey() { string hashLeft = string.Empty; string hashRight = string.Empty; string encry1 = string.Empty; string ticks; try { APIKeyModel _Model = new APIKeyModel(); ticks = DateTime.UtcNow.Ticks.ToString(); // [encry1] CLientIDToken : IPAddress : ticks encry1 = string.Join(":", new string[] { _Model.Token, _Model.IPAddress, ticks }); // [encry2] UniqueID + ticks hashLeft = Convert.ToBase64String(TripleDESAlgorithm.Encryption(encry1, _Model.EncryKey, _Model.IVKey)); hashRight = string.Join(":", new string[] { _Model.UniqueID, ticks.ToString() }); // [CLientIDToken : IPAddress : ticks + UniqueID + ticks] var basestring = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Join(":", hashRight, hashLeft))); return(basestring); } catch (Exception) { throw; } }
public HttpResponseMessage Get(string Id) { if (Id != null) { int _Id = Convert.ToInt32(Id); //Getting Employee Data from Database According to Id Passed. var Response = _EmployeeRepository.EmployeeDetailsByEmployeeNo(_Id); //Serializing Object which we have got from Database. string SerializeData = JsonConvert.SerializeObject(Response); //Encrypting Serialized Object. byte[] buffer = TripleDESAlgorithm.Encryption(SerializeData, ShareKeys.keyValue, ShareKeys.IVValue); //Sending Response. return(Request.CreateResponse(HttpStatusCode.OK, Convert.ToBase64String(buffer))); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee ID not found")); } }
public static byte[] Encryption(string PlainText, APIKeyModel Model) { return(TripleDESAlgorithm.Encryption(PlainText, Model.EncryKey, Model.IVKey)); }
public static byte[] Encryption(string PlainText) { APIKeyModel _Model = new APIKeyModel(); return(TripleDESAlgorithm.Encryption(PlainText, _Model.EncryKey, _Model.IVKey)); }