public RepositoryResponse <CryptoViewModel <string> > Encrypt([FromBody] JObject model)
        {
            string data      = model.GetValue("data").Value <string>();
            var    encrypted = new JObject(new JProperty("encrypted", data));

            return(new RepositoryResponse <CryptoViewModel <string> >()
            {
                Data = AesEncryptionHelper.EncryptStringToBytes_Aes(encrypted)
            });
        }
Beispiel #2
0
        public JObject SaveEncrypt([FromBody] RequestEncrypted request)
        {
            //var key = Convert.FromBase64String(request.Key); //Encoding.UTF8.GetBytes(request.Key);
            //var iv = Convert.FromBase64String(request.IV); //Encoding.UTF8.GetBytes(request.IV);
            string encrypted = string.Empty;
            string decrypt = string.Empty;
            if (!string.IsNullOrEmpty(request.PlainText))
            {
                encrypted = AesEncryptionHelper.EncryptStringToBytes_Aes(new JObject()).ToString();
            }
            if (!string.IsNullOrEmpty(request.Encrypted))
            {
                //decrypt = SioService.DecryptStringFromBytes_Aes(request.Encrypted, request.Key, request.IV);
            }
            JObject data = new JObject(
                new JProperty("key", request.Key),
                new JProperty("encrypted", encrypted),
                new JProperty("plainText", decrypt));

            return data;
        }