1
0

cryptreal.go 345 B

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