Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pedroalbanese/vmac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

VMAC

ISC License GoDoc Go Report Card

Variable Message Authentication Code

VMAC stands for "Variable Message Authentication Code." It is a method for generating a message authentication code, a type of cryptographic checksum, that ensures the integrity and authenticity of a message. VMAC is designed to provide security against various cryptographic attacks while offering high performance. It uses a block cipher to process variable-length messages and produce a fixed-size authentication tag. This tag can be used to verify that the message has not been altered and comes from a legitimate sender.

Example

package main

import (
	"crypto/aes"
	"fmt"
	"log"

	"github.com/pedroalbanese/vmac"
)

func main() {
	// Example using the AES block cipher
	key := []byte("0000000000000000")
	nonce := []byte("00000000000000")
	message := []byte("The quick brown fox jumps over the lazy dog.")

	block, err := aes.NewCipher(key)
	if err != nil {
		log.Fatal(err)
	}

	// Create a new VMAC using the AES block cipher
	mac, err := vmac.New(block, key, nonce, 16) // 16 is the VMAC size in bytes
	if err != nil {
		log.Fatal(err)
	}

	// Write the message to the VMAC
	_, _ = mac.Write(message)

	// Calculate the VMAC
	calculatedVMAC := mac.Sum()

	// Display the calculated VMAC
	fmt.Printf("VMAC: %x\n", calculatedVMAC)
}

Shamelessly taken from:
https://github.com/nicksnyder/vmac.go

About

VMAC: Message Authentication Code using Universal Hashing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages