github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/transport/internet/kcp/cryptreal.go (about)

     1  package kcp
     2  
     3  import (
     4  	"crypto/aes"
     5  	"crypto/cipher"
     6  	"crypto/sha256"
     7  
     8  	"github.com/v2fly/v2ray-core/v5/common"
     9  )
    10  
    11  func NewAEADAESGCMBasedOnSeed(seed string) cipher.AEAD {
    12  	hashedSeed := sha256.Sum256([]byte(seed))
    13  	aesBlock := common.Must2(aes.NewCipher(hashedSeed[:16])).(cipher.Block)
    14  	return common.Must2(cipher.NewGCM(aesBlock)).(cipher.AEAD)
    15  }