2025-04-16 18:05:21 +08:00
|
|
|
|
using Microsoft.SqlServer.Server;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2025-05-04 19:55:10 +08:00
|
|
|
|
namespace Obfuz.ObfusPasses.SymbolObfus
|
2025-04-16 18:05:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public class NameScope : NameScopeBase
|
|
|
|
|
{
|
2025-05-05 10:24:13 +08:00
|
|
|
|
private readonly string _namePrefix;
|
2025-04-16 18:05:21 +08:00
|
|
|
|
private readonly List<string> _wordSet;
|
|
|
|
|
private int _nextIndex;
|
|
|
|
|
|
2025-05-05 10:24:13 +08:00
|
|
|
|
public NameScope(string namePrefix, List<string> wordSet)
|
2025-04-16 18:05:21 +08:00
|
|
|
|
{
|
2025-05-05 10:24:13 +08:00
|
|
|
|
_namePrefix = namePrefix;
|
2025-04-16 18:05:21 +08:00
|
|
|
|
_wordSet = wordSet;
|
|
|
|
|
_nextIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-05 10:14:42 +08:00
|
|
|
|
protected override void BuildNewName(StringBuilder nameBuilder, string originalName, string lastName)
|
2025-04-16 18:05:21 +08:00
|
|
|
|
{
|
2025-05-05 10:24:13 +08:00
|
|
|
|
nameBuilder.Append(_namePrefix);
|
2025-04-16 18:05:21 +08:00
|
|
|
|
for (int i = _nextIndex++; ;)
|
|
|
|
|
{
|
|
|
|
|
nameBuilder.Append(_wordSet[i % _wordSet.Count]);
|
|
|
|
|
i = i / _wordSet.Count;
|
|
|
|
|
if (i == 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|