😎新增SAP生成签名接口
This commit is contained in:
parent
431b1a5710
commit
1e1ec2e190
@ -5,6 +5,7 @@
|
||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
|
||||
using Admin.NET.Core;
|
||||
using Admin.NET.Core.Service;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
@ -14,6 +15,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Vistar.Application.Const;
|
||||
@ -36,6 +38,28 @@ public class SapOpenInterfaceService : IDynamicApiController, ITransient
|
||||
_obj132Rep = obj132Rep;
|
||||
_solidWorksManageService = solidWorksManageService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成签名 🔖
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[DisplayName("生成签名")]
|
||||
[AllowAnonymous]
|
||||
public string GenerateSignature(GenerateSignatureInput input)
|
||||
{
|
||||
// 密钥
|
||||
var appSecretByte = Encoding.UTF8.GetBytes(input.AccessSecret);
|
||||
|
||||
// 拼接参数
|
||||
var parameter = $"{input.Method.ToString().ToUpper()}&{input.Url}&{input.AccessKey}&{input.Timestamp}&{input.Nonce}";
|
||||
// 使用 HMAC-SHA256 协议创建基于哈希的消息身份验证代码 (HMAC),以appSecretByte 作为密钥,对上面拼接的参数进行计算签名,所得签名进行 Base-64 编码
|
||||
using HMAC hmac = new HMACSHA256();
|
||||
hmac.Key = appSecretByte;
|
||||
var sign = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(parameter)));
|
||||
return sign;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SAP创建、修改客户档案
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user