首页 / 算法 / 支付相关-算法知识2
支付相关-算法知识2
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了支付相关-算法知识2,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含6795字,纯文字阅读大概需要10分钟。
内容图文
![支付相关-算法知识2](/upload/InfoBanner/zyjiaocheng/1110/842351c6fe6440fe9c97c9c0d325b4d0.jpg)
参考资料:Enveloped and Signed CMS/PKCS #7 Message
资料地址:https://docs.microsoft.com/en-us/previous-versions/bb885086(v=vs.90)?redirectedfrom=MSDN
参考资料:
资料地址:
project:aspose-pdf/Aspose.Pdf-for-.NET
File name: Examples/CSharp/AsposePDF/DigitallySign.cs
using System.IO; using System; using Aspose.Pdf; using Aspose.Pdf.Facades; using System.Collections; using Aspose.Pdf.Forms; namespace Aspose.Pdf.Examples.CSharp.AsposePDF.SecuritySignatures { public class DigitallySign { public static void Run() { try { // ExStart:DigitallySign // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures(); string pbxFile = ""; string inFile = dataDir + @"DigitallySign.pdf"; string outFile = dataDir + @"DigitallySign_out.pdf"; using (Document document = new Document(inFile)) { using (PdfFileSignature signature = new PdfFileSignature(document)) { PKCS7 pkcs = new PKCS7(pbxFile, "WebSales"); // Use PKCS7/PKCS7Detached objects DocMDPSignature docMdpSignature = new DocMDPSignature(pkcs, DocMDPAccessPermissions.FillingInForms); System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100); // Set signature appearance signature.SignatureAppearance = dataDir + @"aspose-logo.jpg"; // Create any of the three signature types signature.Certify(1, "Signature Reason", "Contact", "Location", true, rect, docMdpSignature); // Save output PDF file signature.Save(outFile); } } using (Document document = new Document(outFile)) { using (PdfFileSignature signature = new PdfFileSignature(document)) { IList sigNames = signature.GetSignNames(); if (sigNames.Count > 0) // Any signatures? { if (signature.VerifySigned(sigNames[0] asstring)) // Verify first one { if (signature.IsCertified) // Certified? { if (signature.GetAccessPermissions() == DocMDPAccessPermissions.FillingInForms) // Get access permission { // Do something } } } } } } // ExEnd:DigitallySign } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }
----------------------------------------------------------------
参考资料:Encrypt and Decrypt Data with C#
资料地址:https://www.codeproject.com/articles/14151/encrypt-and-decrypt-data-with-csharp-2
public static string Encrypt(string toEncrypt, bool useHashing) { byte[] keyArray; byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt); System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); // Get the key from config filestring key = (string)settingsReader.GetValue("SecurityKey", typeof(String)); //System.Windows.Forms.MessageBox.Show(key); //If hashing use get hashcode regards to your keyif (useHashing) { MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider(); keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key)); //Always release the resources and flush data //of the Cryptographic service provide. Best Practice hashmd5.Clear(); } else keyArray = UTF8Encoding.UTF8.GetBytes(key); TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider(); //set the secret key for the tripleDES algorithm tdes.Key = keyArray; //mode of operation. there are other 4 modes. We choose ECB(Electronic code Book) tdes.Mode = CipherMode.ECB; //padding mode(if any extra byte added) tdes.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = tdes.CreateEncryptor(); //transform the specified region of bytes array to resultArraybyte[] resultArray = cTransform.TransformFinalBlock (toEncryptArray, 0, toEncryptArray.Length); //Release resources held by TripleDes Encryptor tdes.Clear(); //Return the encrypted data into unreadable string formatreturn Convert.ToBase64String(resultArray, 0, resultArray.Length); }
public static string Decrypt(string cipherString, bool useHashing) { byte[] keyArray; //get the byte code of the stringbyte[] toEncryptArray = Convert.FromBase64String(cipherString); System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); //Get your key from config file to open the lock!string key = (string)settingsReader.GetValue("SecurityKey", typeof(String)); if (useHashing) { //if hashing was used get the hash code with regards to your key MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider(); keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key)); //release any resource held by the MD5CryptoServiceProvider hashmd5.Clear(); } else { //if hashing was not implemented get the byte code of the key keyArray = UTF8Encoding.UTF8.GetBytes(key); } TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider(); //set the secret key for the tripleDES algorithm tdes.Key = keyArray; //mode of operation. there are other 4 modes. //We choose ECB(Electronic code Book) tdes.Mode = CipherMode.ECB; //padding mode(if any extra byte added) tdes.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = tdes.CreateDecryptor(); byte[] resultArray = cTransform.TransformFinalBlock (toEncryptArray, 0, toEncryptArray.Length); //Release resources held by TripleDes Encryptor tdes.Clear(); //return the Clear decrypted TEXTreturn UTF8Encoding.UTF8.GetString(resultArray); }
-------------------------------------------------------------------------------
参考资料:https://www.c-sharpcorner.com/UploadFile/f8fa6c/data-encryption-and-decryption-in-C-Sharp/
资料地址:Data Encryption And Decryption in C#
using System; using System.Security.Cryptography; using System.Text; namespace DataEncrypterDecrypter { public class CryptoEngine { public static string Encrypt(string input, string key) { byte[] inputArray = UTF8Encoding.UTF8.GetBytes(input); TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider(); tripleDES.Key = UTF8Encoding.UTF8.GetBytes(key); tripleDES.Mode = CipherMode.ECB; tripleDES.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = tripleDES.CreateEncryptor(); byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length); tripleDES.Clear(); return Convert.ToBase64String(resultArray, 0, resultArray.Length); } publicstaticstring Decrypt(string input, string key) { byte[] inputArray = Convert.FromBase64String(input); TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider(); tripleDES.Key = UTF8Encoding.UTF8.GetBytes(key); tripleDES.Mode = CipherMode.ECB; tripleDES.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = tripleDES.CreateDecryptor(); byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length); tripleDES.Clear(); return UTF8Encoding.UTF8.GetString(resultArray); } } }
关键词:Decrypting PKCS#7 encrypted data in C#
地址:https://stackoverflow.com/questions/1503974/decrypting-pkcs7-encrypted-data-in-c-sharp
地址:https://csharp.hotexamples.com/examples/iTextSharp.text.pdf/PdfPKCS7/-/php-pdfpkcs7-class-examples.html
原文:https://www.cnblogs.com/Tpf386/p/11959764.html
内容总结
以上是互联网集市为您收集整理的支付相关-算法知识2全部内容,希望文章能够帮你解决支付相关-算法知识2所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。