如何在Dart Flutter中为S3存储桶生成身份验证代码

时间:2019-03-01 11:03:23

标签: amazon-s3 dart flutter

如何将生成身份验证.net代码转换为DART?我需要生成一个身份验证密钥。怎么做?因为需要S3存储桶。

还要检查我的JavaScript代码 How to get Image from S3 Bucket in Flutter?

 public JsonResult GetAuthenticationKey() {
            string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string key = ";ross@si";
            string code = AccountController.Encrypt(date, key);
            return Json(code, JsonRequestBehavior.AllowGet);
        }

        public static string Encrypt(string toEncrypt, string key)
        {
            byte[] keyArray;
            byte[] keyArray2; 
            byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);

            keyArray = UTF8Encoding.UTF8.GetBytes(key);
            keyArray2 = System.Convert.FromBase64String("pdFdo="); 

            var tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes.IV = keyArray2;

            ICryptoTransform cTransform = tdes.CreateEncryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0,toEncryptArray.Length);
            return Convert.ToBase64String(resultArray, 0, resultArray.Length);
        }

0 个答案:

没有答案