1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1.OCPPAuth
- {
- internal static class Signature
- {
- public static void Test()
- {
- string signature = GetSignature(
- timestamp: "1731483946",
- partnerid: "523E6CE1-8BA4-4D88-8895-AC05F5B3AE8F",
- saltkey: "L^u9d2Rt@C");
- }
- private static string GetSignature(string timestamp, string partnerid, string saltkey)
- {
- var unencodeText = $"{timestamp}{partnerid}{saltkey}".ToLower();
- var signature = GetSignature(unencodeText);
- return signature;
- }
- private static string GetSignature(string unencodeText)
- {
- if ((unencodeText == null) || (unencodeText.Length == 0))
- {
- return String.Empty;
- }
- unencodeText = unencodeText.ToLower();
- MD5 md5 = MD5.Create();// new MD5CryptoServiceProvider();
- byte[] textToHash = Encoding.UTF8.GetBytes(unencodeText);
- byte[] result = md5.ComputeHash(textToHash);
- return BitConverter.ToString(result).Replace("-", "").ToLower();
- }
- }
- }
|