github.com/xraypb/xray-core@v1.6.6/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/xraypb/xray-core/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  }