dat2img

package
v0.0.0-...-82cbb0b Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENV_FFMPEG_PATH = "FFMPEG_PATH"
	MinRatio        = 0.6
	FixSliceHeaders = true
)

Variables

View Source
var (
	// Common image format definitions
	JPG     = Format{Header: []byte{0xFF, 0xD8, 0xFF}, Ext: "jpg"}
	PNG     = Format{Header: []byte{0x89, 0x50, 0x4E, 0x47}, Ext: "png"}
	GIF     = Format{Header: []byte{0x47, 0x49, 0x46, 0x38}, Ext: "gif"}
	TIFF    = Format{Header: []byte{0x49, 0x49, 0x2A, 0x00}, Ext: "tiff"}
	BMP     = Format{Header: []byte{0x42, 0x4D}, Ext: "bmp"}
	WXGF    = Format{Header: []byte{0x77, 0x78, 0x67, 0x66}, Ext: "wxgf"}
	Formats = []Format{JPG, PNG, GIF, TIFF, BMP, WXGF}

	// Updated V4 definitions to match Dart implementation (6 bytes signature)
	// V4 Type 1: 0x07 0x08 0x56 0x31 0x08 0x07
	V4Format1 = Format{Header: []byte{0x07, 0x08, 0x56, 0x31, 0x08, 0x07}, AesKey: []byte("cfcd208495d565ef")}
	// V4 Type 2: 0x07 0x08 0x56 0x32 0x08 0x07
	V4Format2 = Format{Header: []byte{0x07, 0x08, 0x56, 0x32, 0x08, 0x07}, AesKey: []byte("0000000000000000")} // User needs to provide key
	V4Formats = []*Format{&V4Format1, &V4Format2}

	// WeChat v4 related constants
	V4XorKey byte = 0x37               // Default XOR key for WeChat v4 dat files
	JpgTail       = []byte{0xFF, 0xD9} // JPG file tail marker
)
View Source
var (
	FFmpegMode = false
	FFMpegPath = "ffmpeg"
)

Functions

func Add2Trak

func Add2Trak(init *mp4.InitSegment, frag *mp4.Fragment, index int, data [][]byte) error

func Convert2JPG

func Convert2JPG(data []byte) ([]byte, error)

func ConvertAnime2GIF

func ConvertAnime2GIF(animeFrames [][]byte, maskFrames [][]byte) ([]byte, error)

ConvertAnime2GIF convert anime frames and mask frames to mp4 FIXME No longer need to write to temporary files

func Dat2Image

func Dat2Image(data []byte) ([]byte, string, error)

Dat2Image converts WeChat dat file data to image data

func Dat2ImageV4

func Dat2ImageV4(data []byte, aesKey []byte) ([]byte, string, error)

Dat2ImageV4 processes WeChat v4 dat image files Refactored to match Dart implementation logic

func ScanAndSetXorKey

func ScanAndSetXorKey(dirPath string) (byte, error)

ScanAndSetXorKey scans a directory to calculate and set the global XOR key

func SetAesKey

func SetAesKey(key string)

func Transmux2MP4

func Transmux2MP4(data []byte) ([]byte, error)

func TransmuxAnime2MP4

func TransmuxAnime2MP4(animeFrames [][]byte, maskFrames [][]byte) ([]byte, error)

func Wxam2pic

func Wxam2pic(data []byte) ([]byte, string, error)

Types

type AesKeyValidator

type AesKeyValidator struct {
	Path          string
	EncryptedData []byte
	TemplateFile  string // 用于验证的样本文件路径
	// TemplateSource:
	// - "t.dat": 来自 *_t.dat(优先且稳定)
	// - "fallback": 来自普通 .dat 的备用样本(可能不稳定/不匹配)
	// - "none": 未找到样本
	TemplateSource string
}

func NewImgKeyValidator

func NewImgKeyValidator(path string) *AesKeyValidator

func (*AesKeyValidator) Validate

func (v *AesKeyValidator) Validate(key []byte) bool

type Format

type Format struct {
	Header []byte
	AesKey []byte
	Ext    string
}

Format defines the header and extension for different image types

type Partition

type Partition struct {
	Offset int
	Size   int
	Ratio  float64
}

type Partitions

type Partitions struct {
	Partitions []Partition
	MaxRatio   float64
	MaxIndex   int
}

func (*Partitions) LikeAnime

func (p *Partitions) LikeAnime() bool

Jump to

Keyboard shortcuts

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