Refine must2 and apply NewAesGcm() to all usage

This commit is contained in:
风扇滑翔翼
2025-08-10 11:20:20 +00:00
committed by GitHub
parent 0cceea75da
commit 68ae33c9e5
10 changed files with 22 additions and 70 deletions

View File

@@ -6,10 +6,10 @@ import (
"crypto/sha256"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/crypto"
)
func NewAEADAESGCMBasedOnSeed(seed string) cipher.AEAD {
hashedSeed := sha256.Sum256([]byte(seed))
aesBlock := common.Must2(aes.NewCipher(hashedSeed[:16])).(cipher.Block)
return common.Must2(cipher.NewGCM(aesBlock)).(cipher.AEAD)
return crypto.NewAesGcm(hashedSeed[:])
}