filematcher

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 3 Imported by: 1

README

FileMatcher

A Simple File Detector to infer binary file types based on some criteria (magic numbers, etc...)

Example

package main

import (
	"fmt"
	"os"
	" github.com/ahmedalkabir/filematcher"
)

func main() {
	file, err := os.Open("./file.docx")

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	defer file.Close()

	buff := make([]byte, 550)
	_, err = file.Read(buff)

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	filetype, _ := filematcher.Match(buff)
	fmt.Println(filetype.Type)

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSumMD5 added in v0.0.2

func CheckSumMD5(buf []byte, len_buf int) [16]byte

func Match

func Match(buf []byte) (types.FileMatcher, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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