コード例 #1
0
        public static ResponseView <TokenModel> TryGetTokenModel(string source)
        {
            ResponseView <TokenModel> response = null;

            if (string.IsNullOrWhiteSpace(source))
            {
                response = new ResponseView <TokenModel>("无效用户", false, null);
                return(response);
            }
            try
            {
                IEncrypted encrypted = new AesEncrypt(DEFAULTKEY, DEFAULTIV);

                var deEnctrypedStr = encrypted.CryptStr(source);

                var model = JsonPase.Deserialize <TokenModel>(deEnctrypedStr);

                response = new ResponseView <TokenModel>("", true, model);
            }
            catch (Exception ex)
            {
                response = new ResponseView <TokenModel>("非法用户", false, null);
            }
            return(response);
        }
コード例 #2
0
ファイル: UnitTest4.cs プロジェクト: hessli/Able.Store
        public void TestW()
        {
            Base64 uy = new Base64();

            //var f= uy.Base64EnCode("12345678张三李四");//\u001f 这个表示的是一个编码的对应值,其实也就是一个数字


            var qs = uy.Base64EnCode("12345678张三李四");

            var fs = uy.Base64EnCode("abcdsdfdsdfdsdfdsssssssf");

            //输入一个字符串,经过64编码后有24个字符,获取字节数只有16个
            //tiihtNczf5v6AKRyjwEUhQ==

            IEncrypted encrypted = new AesEncrypt(fs, qs);

            var q = encrypted.CryptStr(Newtonsoft.Json.JsonConvert.SerializeObject(new
            {
                Name = "张三",
                Age  = 14
            }));


            var b = encrypted.DecryptStr(q);
        }
コード例 #3
0
        public string ToToken()
        {
            IEncrypted encrypted = new AesEncrypt(DEFAULTKEY, DEFAULTIV);

            var str = JsonPase.Serialize(this);

            var data = encrypted.CryptStr(str);

            return(data);
        }