Comments (2)
原实现:可以实现go aes加密 js解密.
func AesCbcEncrypt(data, key []byte) []byte {
block, _ := aes.NewCipher(key)
blockSize := block.BlockSize()
data = pkcs7Padding(data, blockSize)
blockMode := cipher.NewCBCEncrypter(block, key[:blockSize])
encrypted := make([]byte, len(data))
blockMode.CryptBlocks(encrypted, data)
return encrypted
}
func AesCbcDecrypt(encrypted, key []byte) []byte {
block, _ := aes.NewCipher(key)
blockSize := block.BlockSize()
blockMode := cipher.NewCBCDecrypter(block, key[:blockSize])
decrypted := make([]byte, len(encrypted))
blockMode.CryptBlocks(decrypted, encrypted)
decrypted = pkcs7UnPadding(decrypted)
return decrypted
}
from lancet.
原实现:可以实现go aes加密 js解密.
func AesCbcEncrypt(data, key []byte) []byte { block, _ := aes.NewCipher(key) blockSize := block.BlockSize() data = pkcs7Padding(data, blockSize) blockMode := cipher.NewCBCEncrypter(block, key[:blockSize]) encrypted := make([]byte, len(data)) blockMode.CryptBlocks(encrypted, data) return encrypted } func AesCbcDecrypt(encrypted, key []byte) []byte { block, _ := aes.NewCipher(key) blockSize := block.BlockSize() blockMode := cipher.NewCBCDecrypter(block, key[:blockSize]) decrypted := make([]byte, len(encrypted)) blockMode.CryptBlocks(decrypted, encrypted) decrypted = pkcs7UnPadding(decrypted) return decrypted }
好呢,谢谢
from lancet.
Related Issues (20)
- 如何使用datetime包获得指定时区的时间呢 HOT 2
- Windows下使用fileutil.zip 打包出来的内容不正确 HOT 6
- IsWeekend 函数可以考虑移除 HOT 2
- 能否增加下SM国密系列包 HOT 1
- GenerateRsaKey 能否直接输出[]Byte HOT 7
- slice.Unique能否增加predicate参数 HOT 1
- 建议AesCbcEncrypt支持自定义iv向量 HOT 1
- good project ,but get public ip is error HOT 5
- 设置超时时间没有效果 HOT 1
- 有时候两个结构很相似,只是扩展了部分字段 HOT 1
- 队列能自动扩容嘛 HOT 2
- sendRequest建议支持context HOT 2
- Promise内存布局优化,以及内存固定bug HOT 1
- [datastructure]使用 CopyOnWriteList 在测试中出现修改元素问题
- fileutil.MiMeType 不是很准确 HOT 1
- param precision of mathutil.Cos isn't used HOT 2
- 读写csv文件应当考虑可以自定义分隔符 HOT 2
- Feature Request: Read Large Files by Line and Support Seek HOT 1
- AesEcbDecrypt 以及slice的删除有问题: HOT 2
- 多线程安全 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lancet.