相关疑难解决方法(0)

AES-CTR在Go中加密并在CryptoJS中解密

我在使用CryptoJS解密使用Go lang加密的文本时遇到问题.

这是Go代码:https: //play.golang.org/p/xCbl48T_iN

package main

import (
    "crypto/aes"
    "crypto/cipher"
    "encoding/base64"
    "fmt"
)

func main() {
    key := []byte("1234567890123456")
    plaintext := []byte("text can be a random lenght")

    block, err := aes.NewCipher(key)
    if err != nil {
        panic(err)
    }

    // The IV needs to be unique, but not secure. Therefore it's common to
    // include it at the beginning of the ciphertext.
    // BTW (only for test purpose) I don't include it

    ciphertext := make([]byte, len(plaintext))

    iv := []byte{'\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f','\x0f'} …
Run Code Online (Sandbox Code Playgroud)

javascript encryption cryptography go cryptojs

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

标签 统计

cryptography ×1

cryptojs ×1

encryption ×1

go ×1

javascript ×1