MFN Integration Guide
  • What is MFN
  • Overview
    • Getting started
    • Integration methods
    • Disclaimer / IPO
    • Caching
    • Checklist after integration
  • Integration methods
    • On-Demand API
    • Synced API
    • MFN Loader
    • IFrame Widget
  • Wordpress Plugin
  • MFN Widgets
    • Report archive
    • Email Subscription Widget
    • Media collection
  • API
    • Feed
    • Model
      • Tags
    • Demo Data
    • WebSub
      • Endpoint
      • Subscribe (optional)
      • Ping Extension (optional)
      • Code samples
      • Misc
    • Archive
    • Email Subscription Guide
Powered by GitBook
On this page
  • C#
  • Go

Was this helpful?

  1. API
  2. WebSub

Code samples

WebSub HMAC verification

C#

using System;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
					
public class Program
{
	public static void Main()
	{
		Encoding utf8 = Encoding.UTF8;

		String client_secret = "supersecret";
		
		HMACSHA256 hmac_new_content = new HMACSHA256(utf8.GetBytes(client_secret));
		String http_body = "{.....}";
		Byte[] new_content_sig = hmac_new_content.ComputeHash(utf8.GetBytes(http_body));

		Console.WriteLine(BitConverter.ToString(new_content_sig).Replace("-", ""));
	}
}

Go

package main

import (
	"crypto/hmac"
	"crypto/sha256"
	"encoding/hex"
	"fmt"
)

func verificationNewContent() {
	secret := "supersecret"
	hm := hmac.New(sha256.New, []byte(secret))
	httpBody := `{....}`
	_, err := hm.Write([]byte(httpBody))
	if err != nil {
		fmt.Println(err)
	}
	hash := hex.EncodeToString(hm.Sum(nil))
	fmt.Println(hash)
}
PreviousPing Extension (optional)NextMisc

Last updated 3 years ago

Was this helpful?