|
|
|
|
using AttachmentDemo.Model;
|
|
|
|
|
using Kingo.Crypto.SM.Core;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace KAttachmentDemo.Helper
|
|
|
|
|
{
|
|
|
|
|
public class JymHelper
|
|
|
|
|
{
|
|
|
|
|
public static string GetTempStringA(AttachmentInfo attachmentInfo)
|
|
|
|
|
{
|
|
|
|
|
//A = ZSDM; PSRY; PSFYJ; PSJD; PSHGJ; Longitude; Latitude; PSSJ; FJHXZ采用英文分号拼接后的字符串
|
|
|
|
|
return $"{attachmentInfo.ZSDM};{attachmentInfo.PSRY};{attachmentInfo.PSFYJ};{attachmentInfo.PSJD};{attachmentInfo.PSHGJ};{attachmentInfo.Longitude};{attachmentInfo.Latitude};{attachmentInfo.PSSJ};{attachmentInfo.FJHXZ}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 正式校验码
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="attachmentInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string GetStringA(AttachmentInfo attachmentInfo)
|
|
|
|
|
{
|
|
|
|
|
// A = FJHXZ,PSSJ,Longitude,Latitude,PSFYJ,PSJD,PSHGJ,PSRY,ZSDM采用英文逗号拼接后的字符串
|
|
|
|
|
// B = SM3(A),采用SM3进行哈希值计算(十六进制大写字符串)。
|
|
|
|
|
//C = SM2(B),采用私钥对哈希值签名生成校验码(十六进制大写字符串)。
|
|
|
|
|
return $"{attachmentInfo.FJHXZ},{attachmentInfo.PSSJ},{attachmentInfo.Longitude},{attachmentInfo.Latitude},{attachmentInfo.PSFYJ},{attachmentInfo.PSJD},{attachmentInfo.PSHGJ},{attachmentInfo.PSRY},{attachmentInfo.ZSDM}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成校验码
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strA"></param>
|
|
|
|
|
/// <param name="privateKey"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string CreateJYM(string strA, string privateKey)
|
|
|
|
|
{
|
|
|
|
|
//A = FJHXZ,PSSJ,Longitude,Latitude,PSFYJ,PSJD,PSHGJ,PSRY,ZSDM采用英文逗号拼接后的字符串
|
|
|
|
|
//B = SM3(A),采用SM3进行哈希值计算(十六进制大写字符串)。
|
|
|
|
|
//C = SM2(B),采用私钥对哈希值签名生成校验码(十六进制大写字符串)
|
|
|
|
|
return SM2.Sign(SM3.Hash(strA), privateKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|