mirror of
https://github.com/fumiama/gofastTEA.git
synced 2026-07-01 23:40:24 +08:00
init
This commit is contained in:
25
tea_1.16_asm.go
Normal file
25
tea_1.16_asm.go
Normal file
@@ -0,0 +1,25 @@
|
||||
//go:build !go1.17 && amd64
|
||||
// +build !go1.17,amd64
|
||||
|
||||
package tea
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// implemented in tea_$GOARCH.s
|
||||
func encrypt(dstlen uintptr, tlen uintptr)
|
||||
func decrypt(datalen uintptr, dstlen uintptr, t *TEA)
|
||||
|
||||
//go:nosplit
|
||||
func (t TEA) Encrypt(src []byte) (dst []byte) {
|
||||
lens := len(src)
|
||||
fill := 10 - (lens+1)&7
|
||||
dst = make([]byte, fill+lens+7)
|
||||
_, _ = rand.Read(dst[0:fill])
|
||||
dst[0] = byte(fill-3) | 0xF8 // 存储pad长度
|
||||
copy(dst[fill:], src)
|
||||
encrypt(uintptr(*(*unsafe.Pointer)(unsafe.Pointer(&dst)))|uintptr(len(dst)<<40), uintptr(unsafe.Pointer(&t))|(uintptr(len(dst))&0xffffff00_00000000))
|
||||
return dst
|
||||
}
|
||||
Reference in New Issue
Block a user