tea

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: GPL-3.0 Imports: 2 Imported by: 9 modules, 19 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gofastTEA

TEA 编码算法的优化实现

1.17 版本及以上

代码与MiraiGo相比,替换了随机算法为runtime.fastrand,且简化了Decrypt,提升速度如下。

name         old time/op    new time/op    delta
TEAen/16-8      241ns ± 1%     225ns ± 1%  -6.97%  (p=0.000 n=9+10)
TEAen/256-8    1.71µs ± 1%    1.68µs ± 1%  -1.31%  (p=0.000 n=10+9)
TEAen/4K-8     25.0µs ± 1%    25.0µs ± 1%    ~     (p=0.497 n=10+9)
TEAen/32K-8     203µs ± 0%     202µs ± 0%    ~     (p=0.079 n=10+9)
TEAde/16-8      208ns ± 1%     208ns ± 0%    ~     (p=0.914 n=9+9)
TEAde/256-8    1.65µs ± 1%    1.65µs ± 1%    ~     (p=0.429 n=9+10)
TEAde/4K-8     24.7µs ± 1%    24.5µs ± 1%  -0.44%  (p=0.026 n=9+10)
TEAde/32K-8     200µs ± 1%     199µs ± 0%  -0.37%  (p=0.001 n=9+9)

name         old speed      new speed      delta
TEAen/16-8   66.3MB/s ± 1%  71.3MB/s ± 1%  +7.50%  (p=0.000 n=9+10)
TEAen/256-8   150MB/s ± 1%   152MB/s ± 1%  +1.31%  (p=0.000 n=10+9)
TEAen/4K-8    164MB/s ± 1%   164MB/s ± 1%    ~     (p=0.497 n=10+9)
TEAen/32K-8   162MB/s ± 0%   162MB/s ± 0%    ~     (p=0.075 n=10+9)
TEAde/16-8    154MB/s ± 1%   154MB/s ± 0%    ~     (p=0.982 n=9+9)
TEAde/256-8   165MB/s ± 1%   165MB/s ± 1%    ~     (p=0.399 n=9+10)
TEAde/4K-8    167MB/s ± 1%   168MB/s ± 1%  +0.44%  (p=0.026 n=9+10)
TEAde/32K-8   164MB/s ± 1%   165MB/s ± 0%  +0.37%  (p=0.001 n=9+9)

1.16 版本及以下

MiraiGo本身在go1.16版本与在go1.17版本下编译相比,提升速度如下。

name         old time/op    new time/op    delta
TEAen/16-8      252ns ± 0%     241ns ± 1%  -4.09%  (p=0.000 n=9+10)
TEAen/256-8    1.77µs ± 1%    1.70µs ± 0%  -3.85%  (p=0.000 n=9+10)
TEAen/4K-8     25.9µs ± 0%    24.9µs ± 1%  -3.59%  (p=0.000 n=10+10)
TEAen/32K-8     208µs ± 1%     200µs ± 1%  -3.78%  (p=0.000 n=10+10)
TEAde/16-8      216ns ± 1%     208ns ± 1%  -3.80%  (p=0.000 n=10+10)
TEAde/256-8    1.71µs ± 1%    1.65µs ± 1%  -3.44%  (p=0.000 n=10+10)
TEAde/4K-8     25.4µs ± 1%    24.5µs ± 0%  -3.40%  (p=0.000 n=10+10)
TEAde/32K-8     206µs ± 0%     199µs ± 0%  -3.36%  (p=0.000 n=9+10)

name         old speed      new speed      delta
TEAen/16-8   63.5MB/s ± 0%  66.3MB/s ± 1%  +4.27%  (p=0.000 n=9+10)
TEAen/256-8   145MB/s ± 1%   150MB/s ± 0%  +4.01%  (p=0.000 n=9+10)
TEAen/4K-8    158MB/s ± 0%   164MB/s ± 1%  +3.73%  (p=0.000 n=10+10)
TEAen/32K-8   158MB/s ± 1%   164MB/s ± 1%  +3.93%  (p=0.000 n=10+10)
TEAde/16-8    148MB/s ± 1%   154MB/s ± 1%  +3.95%  (p=0.000 n=10+10)
TEAde/256-8   160MB/s ± 1%   165MB/s ± 1%  +3.55%  (p=0.000 n=10+10)
TEAde/4K-8    162MB/s ± 1%   168MB/s ± 0%  +3.52%  (p=0.000 n=10+10)
TEAde/32K-8   159MB/s ± 0%   165MB/s ± 0%  +3.45%  (p=0.000 n=9+9)

Documentation

Overview

Package tea from https://github.com/Mrs4s/MiraiGo/blob/master/binary/tea.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TEA

type TEA [4]uint32

func NewTeaCipher

func NewTeaCipher(key []byte) (t TEA)

func NewTeaCipherLittleEndian added in v0.0.6

func NewTeaCipherLittleEndian(key []byte) (t TEA)

func (TEA) Decrypt

func (t TEA) Decrypt(data []byte) []byte

func (TEA) DecryptLittleEndian added in v0.0.6

func (t TEA) DecryptLittleEndian(data []byte, sumtable [0x10]uint32) []byte

func (TEA) DecryptLittleEndianTo added in v0.0.8

func (t TEA) DecryptLittleEndianTo(data []byte, sumtable [0x10]uint32, dst []byte) (from, to int)

func (TEA) DecryptTo added in v0.0.8

func (t TEA) DecryptTo(data []byte, dst []byte) (from, to int)

func (TEA) Encrypt

func (t TEA) Encrypt(src []byte) (dst []byte)

Encrypt tea 加密 http://bbs.chinaunix.net/thread-583468-1-1.html 感谢xichen大佬对TEA的解释

func (TEA) EncryptLittleEndian added in v0.0.6

func (t TEA) EncryptLittleEndian(src []byte, sumtable [0x10]uint32) (dst []byte)

func (TEA) EncryptLittleEndianTo added in v0.0.8

func (t TEA) EncryptLittleEndianTo(src []byte, sumtable [0x10]uint32, dst []byte) int

func (TEA) EncryptTo added in v0.0.8

func (t TEA) EncryptTo(src []byte, dst []byte) int

func (TEA) ToBytes added in v0.1.1

func (t TEA) ToBytes() [16]byte

func (TEA) ToBytesLittleEndian added in v0.1.1

func (t TEA) ToBytesLittleEndian() [16]byte

Jump to

Keyboard shortcuts

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