Implementation of MD5CryptoServiceProvider in. net Compact Flamework

Source: Internet
Author: User
Tags compact md5
In the. net Flamework full version, encryption classes in the System. Security. Cryptography namespace are well supported. However, the corresponding classes in the namespace are not provided in the Lite version. It is really troublesome to use encryption algorithms when using. net to write a Pocket PC program. There are two methods to solve this problem. OpenNetCF (www.openetcf.org) provides the System. security. simulation of various classes in the Cryptography namespace, but it lacks flexibility: for example, during symmetric encryption, users cannot set attributes such as Padding and CipherMode. In addition, its provision method is inconsistent with the class interface in the full version of. net, which causes confusion to users. Another method is to manually encapsulate the cryptoAPI.
Recently, the MD5CryptoServiceProvider has been implemented out of work requirements. The interfaces of this class are exactly the same as those in the full version.
Implementation of the "System. Security. Cryptography. MD5CryptoServiceProvider" class.

Public sealed class MD5CryptoServiceProvider: MD5
{
Public MD5CryptoServiceProvider ()
{
Initialize ();
M_Disposed = false;
}
Public override void Initialize ()
{
If (m_Disposed)
Throw new ObjectDisposedException (this. GetType (). FullName );
If (m_Hash! = IntPtr. Zero)
{
Crypto. CryptDestroyHash (m_Hash );
}
M_Prov = Crypto. AcquireContext (ProvType. RSA_FULL );
Bool retVal = Crypto. CryptCreateHash (m_Prov, (uint) CalgHash. MD5, IntPtr. Zero, 0, out m_Hash );

}
Protected override void HashCore (byte [] array, int ibStart, int cbSize)
{
If (m_Disposed)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.