小编Hen*_*owo的帖子

Go 只加密 16 字节消息长度的文本吗?

我尝试在 Golang 中使用 AES 加密消息。

func main() {
    key := "mysupersecretkey32bytecharacters"
    plainText := "thisismyplaintextingolang"

    fmt.Println("My Encryption")
    byteCipherText := encrypt([]byte(key), []byte(plainText))
    fmt.Println(byteCipherText)
}

func encrypt(key, plaintext []byte) []byte {
    cphr, err := aes.NewCipher(key)
    if err != nil {
        panic(err)
    }
    ciphertext := make([]byte, len(plaintext))
    cphr.Encrypt(ciphertext, plaintext)
    return ciphertext
}
Run Code Online (Sandbox Code Playgroud)

该函数返回: [23 96 11 10 70 223 95 118 157 250 80 92 77 26 137 224 0 0 0 0 0 0 0 0 0]

在该结果中,只有 16 个非零字节值。这意味着 Go 中的 AES …

encryption aes go

-1
推荐指数
1
解决办法
155
查看次数

标签 统计

aes ×1

encryption ×1

go ×1