AES配置增加秘钥字符表

This commit is contained in:
falcon 2022-09-06 13:54:40 +08:00
parent 5ed2a9997a
commit f197ec7ff5
2 changed files with 6 additions and 1 deletions

View File

@ -11,5 +11,10 @@
/// 秘钥长度。最大32
/// </summary>
public int KeyLength { get => keyLength; set => keyLength = value > 32 ? 32 : value; }
/// <summary>
/// 秘钥字符表
/// </summary>
public string KeyChars { get; set; } = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789,.!/*\";
}
}

View File

@ -73,7 +73,7 @@ namespace Falcon.SugarApi.Encryption
/// <inheritdoc/>
public string GenerateKey() {
var chars = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789,.!/*\";
var chars = this.Config.KeyChars;
var r = new Random();
var len = this.Config.KeyLength;
var sb = new StringBuilder(len);