Class SensitiveDataGenerator
java.lang.Object
cloud.opencode.base.test.data.SensitiveDataGenerator
Sensitive Data Generator - Generates test data that looks real but is fake
敏感数据生成器 - 生成看起来真实但实际是假的测试数据
Generates test data with correct formats (checksums, etc.) but using non-real values to avoid accidental use of real personal information.
生成格式正确(校验和等)但使用非真实值的测试数据,以避免意外使用真实个人信息。
Features | 主要功能:
- Test phone numbers (non-real carrier prefixes) - 测试手机号(非真实运营商前缀)
- Test ID card numbers (valid checksum, fake region) - 测试身份证号(有效校验和,虚假地区)
- Test bank card numbers (Luhn valid, test BIN) - 测试银行卡号(Luhn有效,测试BIN)
- Test email addresses - 测试邮箱地址
Usage Examples | 使用示例:
String phone = SensitiveDataGenerator.testPhone(); // 199xxxxxxxx
String idCard = SensitiveDataGenerator.testIdCard(); // 999999xxxxxxxxxx
String bankCard = SensitiveDataGenerator.testBankCard(); // 622848xxxxxxxxxx
Security | 安全性:
- Thread-safe: Yes (uses ThreadLocalRandom) - 线程安全: 是(使用ThreadLocalRandom)
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-test V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringGenerates a test bank card number with valid Luhn checksum.static StringtestBankCard(String bin) Generates a test bank card number with custom BIN.static StringGenerates a test email address.static StringGenerates a test email address with specified domain.static StringGenerates a test 18-digit ID card number (fake region 999999).static StringtestIdCard(int birthYear) Generates a test ID card with specified birth year.static StringGenerates a test phone number (199 prefix, not assigned to real carriers).static StringGenerates a test phone number with custom prefix.static StringGenerates a test unified social credit code.
-
Method Details
-
testPhone
Generates a test phone number (199 prefix, not assigned to real carriers). 生成测试手机号(199前缀,未分配给真实运营商)。- Returns:
- the test phone number | 测试手机号
-
testPhone
-
testIdCard
Generates a test 18-digit ID card number (fake region 999999). 生成18位测试身份证号(虚假地区999999)。- Returns:
- the test ID card number | 测试身份证号
-
testIdCard
Generates a test ID card with specified birth year. 生成指定出生年份的测试身份证号。- Parameters:
birthYear- the birth year | 出生年份- Returns:
- the test ID card number | 测试身份证号
-
testBankCard
Generates a test bank card number with valid Luhn checksum. 生成带有效Luhn校验和的测试银行卡号。- Returns:
- the test bank card number | 测试银行卡号
-
testBankCard
-
testEmail
Generates a test email address. 生成测试邮箱地址。- Returns:
- the test email address | 测试邮箱地址
-
testEmail
-
testSocialCreditCode
Generates a test unified social credit code. 生成测试统一社会信用代码。- Returns:
- the test code | 测试代码
-