xxtea / xxtea-go Goto Github PK
View Code? Open in Web Editor NEWXXTEA encryption algorithm library for Golang.
License: MIT License
XXTEA encryption algorithm library for Golang.
License: MIT License
package main
import (
"encoding/base64"
"github.com/xxtea/xxtea"
"log"
)
var (
key = []byte("testKey123456789")
cipher = []byte("马年行大运!")
)
func main() {
// encrypt and base64 encode
encCipher := xxtea.Encrypt(cipher, key)
encCipherBase64 := base64.StdEncoding.EncodeToString(encCipher)
log.Println(encCipherBase64)
// base64 decode and decrypt
byteCipher, _ := base64.StdEncoding.DecodeString(encCipherBase64)
src := string(xxtea.Decrypt(byteCipher, key))
log.Println(src)
}
这个在go里面加解密没问题, 把 encCipherBase64 发给 php, base64解码后的数据也一致, 但是 php xxtea解密失败, 没有得到密文.
反之, php 里面加解密也没问题, 把 base64 编码的加密后的数据发给go 进行base64解码, 数据也一致, 但是 go xxtea解密也失败, 得到空白密文.
echo base64_encode(xxtea_encrypt('恭喜发财,马年一切顺利!','testKey123456789'));
//echo xxtea_decrypt(base64_decode(base64_encode(xxtea_encrypt('恭喜发财,马年一切顺利!','testKey123456789'))),'testKey123456789');
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.