cryptreal.go 333 B

1234567891011121314
  1. package kcp
  2. import (
  3. "crypto/aes"
  4. "crypto/cipher"
  5. "crypto/sha256"
  6. "v2ray.com/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. }