public IActionResult TestEncrypt([FromBody] dynamic value) { try { //var keyByteArray = Convert.FromBase64String(key); //var vectorByteArray = Convert.FromBase64String(vector); //var valueByteArray = Convert.FromBase64String(encryptedString); string svalue = Convert.ToString(value); dynamic UserJsonEntity = JsonConvert.DeserializeObject(svalue); //Extract Json string subId = UserJsonEntity["subscriptionId"].Value; string plainText = UserJsonEntity["plainText"].Value; var subscription = _subscriptionService.GetById(int.Parse(subId)); var ekey = _eKeyService.GetActive(subscription.EnterpriseClientId); byte[] encryptedByteArray = _eKeyService.Encrypt(plainText, ekey.Key, ekey.IV); return(Json(new { c = ResultCode.Success, key = ekey.Key, vector = ekey.IV, d = Convert.ToBase64String(encryptedByteArray) })); } catch (Exception ex) { return(Json(new { c = ResultCode.GenericException, d = ex.Message })); } }
private byte[] GetEncryptedString(string plainText, EKey ekey) { return(_eKeyService.Encrypt(plainText, ekey.Key, ekey.IV)); }