[UWP] FIPS启用并使用MD5算法不会抛出任何异常 [英] [UWP] FIPS Enabled and using MD5 algorithm does not throw any exception
问题描述
为什么启用FIPS并使用 MD5算法不会在UWP中抛出任何异常?。
Why FIPS Enabled and using MD5 algorithm does not throw any exception in UWP ?.
我们尝试使用WPF代码,该代码按预期工作,但在UWP App中无效。请参阅下面的代码片段以获取更多详细信息。
We tried with WPF code which works as expected but not working in UWP App.See below code snippet for more details.
WPF代码,当启用FIPS。抛出异常"此实现不是Windows平台FIPS验证的加密算法的一部分。"
WPF code , when FIPS enabled. Throws Exception "This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms."
using (System.Security.Cryptography。 MD5
md5 = System.Security.Cryptography。 MD5 。Create() )
               {
                  
byte [] inputBytes = System.Text。 编码 .ASCII.GetBytes( " tests" );
            
byte [] hashBytes = md5.ComputeHash(inputBytes);
  ;            
//将字节数组转换为十六进制字符串
  ;            
StringBuilder sb =
new
StringBuilder ();
;         
for ( int
i = 0; i< hashBytes.Length; i ++)
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; {
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; sb.Append(hashBytes [i] .ToString( " X2" ));
&NBSP;&NBSP;&NBSP;&NBSP; }
}
对于UWP App ,启用FIPS并使用以下MD5算法时不会抛出任何内容例外
For UWP App, when FIPS Enabled and using the below MD5 algorithm does not throw any exception
为什么不像wpf应用程序一样抛出异常。例外"此实现不是Windows平台FIPS验证的加密算法的一部分。"
var alg =
HashAlgorithmProvider .OpenAlgorithm( HashAlgorithmNames 。Md5);
;&NBSP;
IBuffer buff =
CryptographicBuffer < span style ="font-size:9.5pt; font-family:Consolas; color:black"> .ConvertStringToBinary( " tests" ,
BinaryStringEncoding 。Utf8);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
var crypthas = alg.CreateHash();
var 结果 = crypthas.GetValueAndReset();
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
var hashed = alg.HashData(buff);
var res =
CryptographicBuffer .EncodeToHexString(hashed);
谢谢。
Jyotiranjan
Jyotiranjan
推荐答案
你好JYOTIJULU,
Hello JYOTIJULU,
我已经咨询了这个问题,可能会有一些时间延迟。感谢您的耐心等待。
I've consulted this issue and there might be some time delay. Thank you for you patience.
致以最诚挚的问候,
Barry
这篇关于[UWP] FIPS启用并使用MD5算法不会抛出任何异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!