signer

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package signer provides functionality for signing IDIP requests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	AppId   string `json:"idip-sign-appid"`
	Time    string `json:"idip-sign-time"`
	Rnd     string `json:"idip-sign-rnd"`
	Sign    string `json:"idip-sign"`
	Version string `json:"idip-sign-version"`
}

Header represents the signing headers used in requests

func (Header) Header2Map

func (h Header) Header2Map() map[string]string

Header2Map converts a Header struct to a map[string]string

type ISigner

type ISigner interface {
	Sign(body, tag string) string
	GenSignedHeader(body, tag string, version string) Header
	GetRnd() int
	GetTimestamp() int64
}

ISigner defines the interface for signing operations

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

Signer implements the ISigner interface

func NewSigner

func NewSigner(appId, secret string) (*Signer, error)

NewSigner creates a new Signer instance with the given credentials

func (Signer) GenSignedHeader

func (s Signer) GenSignedHeader(body, tag string, version string) Header

GenSignedHeader generates a complete Header with signature

func (Signer) GetRnd

func (s Signer) GetRnd() int

GetRnd returns the random number used in signing

func (Signer) GetTimestamp

func (s Signer) GetTimestamp() int64

GetTimestamp returns the timestamp used in signing

func (Signer) Sign

func (s Signer) Sign(body, tag string) string

Sign generates a signature for the given body and tag

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL