A complete class is used to generate the RSACryptoServiceProvider Singleton class (. NET)

Source: Internet
Author: User

1 Internal classCcbrsacryptprovider2 {3         Private StaticRSACryptoServiceProvider _providerforsign;4         Private StaticRSACryptoServiceProvider _providerforverifysign;5         Private Static ReadOnly ObjectSignobj =New Object();6         Private Static ReadOnly ObjectVerifysignobj =New Object();7 8         Internal StaticRSACryptoServiceProvider Getinstanceforsign (stringprivatekeyfile)9         {Ten             if(NULL! = _providerforsign)return_providerforsign; One             Lock(signobj) A             { -                 if(NULL! = _providerforsign)return_providerforsign; -                 varProvider =NewRSACryptoServiceProvider (); the provider. Fromxmlstring (Getxmlcontent (Privatekeyfile)); -_providerforsign =provider; -             } -             return_providerforsign; +         } -  +         Internal StaticRSACryptoServiceProvider Getinstanceforverifysign (stringpublickeyfile) A         { at             if(NULL! = _providerforverifysign)return_providerforverifysign; -             Lock(verifysignobj) -             { -                 if(NULL! = _providerforverifysign)return_providerforverifysign; -                 varProvider =NewRSACryptoServiceProvider (); - provider. Fromxmlstring (Getxmlcontent (Publickeyfile)); in_providerforverifysign =provider; -             } to             return_providerforverifysign; +         } -  the         Private Static stringGetxmlcontent (stringFilePath) *         { $             returnFile.readalltext (filePath);Panax Notoginseng         } -  the         PrivateCcbrsacryptprovider () +         { A         } the}

A complete class is used to generate the RSACryptoServiceProvider Singleton class (. NET)

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.