草庐IT

token_key_type

全部标签

c# - 三重 DES : Specified key is a known weak key for 'TripleDES' and cannot be used

我正在使用.NET3.0类System.Security.Cryptography.MACTripleDES类来生成MAC值。不幸的是,我正在使用使用“1111111111111111”(十六进制)作为单一长度DESkey的硬件设备。System.Security.Cryptography库会对key进行完整性检查,如果您尝试使用加密强度较弱的key,则会返回异常。例如:byte[]key=newbyte[24];for(inti=0;i抛出异常System.Security.Cryptography.CryptographicException:Specifiedkeyisaknow

c# - 每个项目都应该使用单独的强名称 key (.snk) 进行签名吗?

在我的VisualStudio解决方案中,我有一个网站和4-5个引用的类库项目,其中一些还引用了外部第三方程序集。我被赋予了为这些项目的程序集签名的任务。我的理解是签名的目的是不是每个人都可以在不提供其公钥和版本详细信息的情况下使用我们的程序集,对吗?我应该使用一个强名称key(.snk)对这些项目的所有程序集进行签名,还是应该使用单独的强名称key对每个程序集进行签名?强名称key密码保护的目的是什么?你会怎么做?非常感谢, 最佳答案 thatthepurposeofsigningisthatnoteveryonebeingabl

c# - 拒绝 token 请求时自定义 OWIN/OAuth HTTP 状态代码

我导出了OAuthAuthorizationServerProvider为了验证客户端和资源所有者。当我验证资源所有者时,我发现他们的凭据无效,我调用context.Rejected(),HTTP响应随附HTTP/400错误请求状态代码,而我期望HTTP/401Unauthorized。如何自定义OAuthAuthorizationServerProvider的响应HTTP状态代码? 最佳答案 这就是我们覆盖OwinMiddleware的方式...首先我们在Owin之上创建了我们自己的中间件...我认为我们遇到了与您类似的问题。首先

c# - ASP.NET MVC : Views using a model type that is loaded by MEF can't be found by the view engine

我正在尝试创建一个框架,以允许将Controller和View动态导入到MVC应用程序中。到目前为止,它是这样工作的:我正在使用.NET4、ASP.NETMVC3RC和RazorViewEngine每个项目都使用MEF导出和导入Controller-我将给定项目中的一组Controller和View称为“模块”BuildManager使用应用前启动方法和BuildManager.AddReferencedAssembly动态引用使用MEF发现的程序集。使用构建事件将二进制文件(来自导出项目)和View复制到目标项目的文件夹结构中使用自定义Controller工厂选择Controller

c# - .Net Core JwtBearer 身份验证不拒绝过期的 token

我正在生成JWT以用于我的WebApi项目。我将token设置为在一分钟后过期,以便我可以测试它是否在过期日期后拒绝提交token。CreateTokenControllerpublicasyncTaskCreateToken([FromBody]CredentialModelmodel){varuser=await_unitOfWork.UserManager.FindByNameAsync(model.UserName);if(user==null)returnBadRequest();if(Hasher.VerifyHashedPassword(user,user.Passwor

c# - 为什么这段代码会提示 "the arity of the generic type definition"?

我有一个通用类型:classDictionaryComparer:IEqualityComparer>还有一个工厂方法,它将(应该)为给定的字典类型创建此类的实例。privatestaticIEqualityComparerCreateDictionaryComparer(){Typedef=typeof(DictionaryComparer);Debug.Assert(typeof(T).IsGenericType);Debug.Assert(typeof(T).GetGenericArguments().Length==2);Typet=def.MakeGenericType(ty

c# - Google OAuth2 服务帐户访问 token 请求提供 'Invalid Request' 响应

我正在尝试通过服务器到服务器方法与我的应用启用的BigQueryAPI进行通信。我已勾选此Googleguide上的所有方框在C#中尽我所能构建我的JWT。我已经对所有必要的内容进行了Base64Url编码。但是,我从google得到的唯一响应是400BadRequest"error":"invalid_request"我已经从这些其他SO问题中确定了以下所有内容:ThesignatureisproperlyencryptedusingRSAandSHA256IamusingPOSTandusingapplication/x-www-form-urlencodedcontenttype

c# - The non-generic method cannot be used with type arguments in this context 是什么意思?

我有以下类和方法:publicclassUserManager:IDisposablewhereTUser:class,global::Microsoft.AspNet.Identity.IUserwhereTKey:global::System.IEquatable{publicvirtualTaskFindByIdAsync(TKeyuserId);和:privateApplicationUserManager_userManager;publicApplicationUserManagerUserManager{get{return_userManager??Request.Ge

c# - "The binary operator Add is not defined for the types ' System.String ' and ' System.String '."-- 真的吗?

尝试运行以下代码时:Expression>stringExpression=Expression.Lambda>(Expression.Add(stringParam,Expression.Constant("A")),newList(){stringParam});stringAB=stringExpression.Compile()("B");我收到标题中提到的错误:“二元运算符Add没有为类型‘System.String’和‘System.String’定义。”真的是这样吗?显然在C#中它有效。在C#中执行strings="A"+"B"是表达式编译器无法访问的特殊语法糖吗?

c# - 从仅给定 Type 实例的 MEF 容器中获取导出

我有一个场景,我必须从我的CompositionContainer实例中导出,但我只有一个Type可以使用;我在编译时不知道类型,因此我无法以正常的通用方式检索导出的对象。通常你会这样做:_container.GetExportedObject();但就我而言,我有这个:TypesomeType=...;_container.HowDoIGetTheExport(someType);有什么想法吗? 最佳答案 找到答案:varexport=_container.GetExports(someType,null,null).FirstO