使用我们的简单工具创建符合格式的随机IBAN或验证现有的IBAN。非常适合测试金融应用程序、银行软件和教育用途。
国际银行账户号码(IBAN)生成器和验证器是一个综合工具,旨在用于金融应用程序、银行软件和教育环境中的测试和验证。这个用户友好的应用程序提供了两个基本功能:生成随机但符合格式的 IBAN 和验证用户输入的 IBAN 的结构完整性。无论您是开发人员在测试金融软件,还是 QA 专家在验证银行应用程序,或是教育工作者在解释国际银行标准,这个工具都提供了一个简单的解决方案,无需复杂的配置或第三方集成。
IBAN(国际银行账户号码)是国际标准化的账户标识符,用于促进跨境交易并减少国际汇款中的错误。每个 IBAN 由国家代码、校验位和基本银行账户号码(BBAN)组成,后者遵循特定国家的格式。我们的工具支持多种国家格式,并确保所有生成的 IBAN 都通过 ISO 13616 标准中规定的 MOD 97 验证算法。
一个 IBAN 由最多 34 个字母数字字符组成,尽管确切的长度因国家而异。标准结构包括:
例如,德国的 IBAN 遵循结构 DE2!n8!n10!n
,其中:
DE
是国家代码2!n
表示两个数字的校验位8!n
表示八位银行代码10!n
表示十位账户号码不同国家有不同的 BBAN 格式,导致 IBAN 长度各异:
国家 | 长度 | 结构 | 示例 |
---|---|---|---|
德国 (DE) | 22 | DE2!n8!n10!n | DE89370400440532013000 |
英国 (GB) | 22 | GB2!n4!a6!n8!n | GB29NWBK60161331926819 |
法国 (FR) | 27 | FR2!n5!n5!n11!c2!n | FR1420041010050500013M02606 |
西班牙 (ES) | 24 | ES2!n4!n4!n1!n1!n10!n | ES9121000418450200051332 |
意大利 (IT) | 27 | IT2!n1!a5!n5!n12!c | IT60X0542811101000000123456 |
IBAN 验证过程使用 MOD 97 算法,如 ISO 7064 标准所规定。其工作原理如下:
在数学上,这表示为:
我们的验证器实现了这一算法,以验证用户输入的任何 IBAN 的结构完整性。
IBAN 生成器创建随机但有效的 IBAN 以供测试。主要功能包括:
生成器通过以下方式创建 IBAN:
IBAN 验证器检查用户输入的 IBAN 的结构完整性。主要功能包括:
验证器执行多个检查:
IBAN 生成器和验证工具在不同领域服务于多种目的:
虽然我们的 IBAN 生成器和验证工具为测试目的提供了简化的体验,但还有其他替代方案可供考虑:
我们的工具填补了这些替代方案之间的空白,提供了一个简单、可访问的界面,用于生成和验证,无需技术集成或付费订阅。
IBAN(国际银行账户号码)是一种标准化的国际编号系统,旨在跨国界识别银行账户。它由国际标准化组织(ISO)制定,以促进无误的国际交易。
IBAN 生成器创建结构上有效的 IBAN,这些 IBAN 通过 ISO 13616 标准中规定的 MOD 97 校验算法。虽然生成的 IBAN 在数学上是有效的,但它们是随机的,并不与实际银行账户关联,因此非常适合测试,但不适用于真实交易。
该工具目前支持德国、英国、法国、西班牙、意大利、荷兰、瑞士、奥地利、比利时和波兰的 IBAN 格式。这些国家涵盖了欧洲最常用的 IBAN 格式。
不可以。该生成器创建的 IBAN 在结构上是有效的,但随机生成。它们与真实银行账户无关,仅应用于测试、教育或演示目的。
验证器检查 IBAN 的几个方面:
不重要。虽然 IBAN 通常以空格显示以提高可读性(通常分为四个字符一组),但在验证过程中会忽略空格。我们的工具处理格式化和未格式化的 IBAN。
不会。该工具完全在您的浏览器中运行。没有 IBAN 数据被发送到任何服务器、存储或与第三方共享。您的数据保持私密和安全。
目前,该工具仅验证下拉列表中支持的国家的 IBAN。如果您需要验证其他国家的 IBAN,请通过反馈表告知我们。
IBAN 可能因多种原因验证失败:
我们欢迎反馈以改进该工具。请使用页面底部链接访问反馈表,报告任何问题或建议改进。
对于有兴趣在自己应用程序中实现 IBAN 验证和生成的开发人员,以下是各种编程语言的代码示例:
1function validateIban(iban) {
2 // 移除空格并转换为大写
3 const cleanedIban = iban.replace(/\s/g, '').toUpperCase();
4
5 // 检查基本格式
6 if (!/^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$/.test(cleanedIban)) {
7 return false;
8 }
9
10 // 重新排列并将字母转换为数字
11 const rearranged = cleanedIban.substring(4) + cleanedIban.substring(0, 4);
12 const converted = rearranged.split('').map(char => {
13 if (/[A-Z]/.test(char)) {
14 return (char.charCodeAt(0) - 55).toString();
15 }
16 return char;
17 }).join('');
18
19 // 计算模 97
20 let remainder = 0;
21 for (let i = 0; i < converted.length; i++) {
22 remainder = (remainder * 10 + parseInt(converted[i], 10)) % 97;
23 }
24
25 return remainder === 1;
26}
27
28// 示例用法
29console.log(validateIban('DE89 3704 0044 0532 0130 00')); // true
30console.log(validateIban('GB29 NWBK 6016 1331 9268 19')); // true
31console.log(validateIban('DE89 3704 0044 0532 0130 01')); // false (无效的校验位)
32
1def validate_iban(iban):
2 # 移除空格并转换为大写
3 iban = iban.replace(' ', '').upper()
4
5 # 基本格式检查
6 if not (len(iban) > 4 and iban[:2].isalpha() and iban[2:4].isdigit()):
7 return False
8
9 # 将前 4 个字符移到末尾
10 rearranged = iban[4:] + iban[:4]
11
12 # 将字母转换为数字(A=10,B=11,...,Z=35)
13 converted = ''
14 for char in rearranged:
15 if char.isalpha():
16 converted += str(ord(char) - 55)
17 else:
18 converted += char
19
20 # 检查模 97 是否等于 1
21 return int(converted) % 97 == 1
22
23# 示例用法
24print(validate_iban('DE89 3704 0044 0532 0130 00')) # True
25print(validate_iban('GB29 NWBK 6016 1331 9268 19')) # True
26print(validate_iban('DE89 3704 0044 0532 0130 01')) # False (无效的校验位)
27
1public class IbanValidator {
2 public static boolean validateIban(String iban) {
3 // 移除空格并转换为大写
4 String cleanedIban = iban.replaceAll("\\s", "").toUpperCase();
5
6 // 基本格式检查
7 if (!cleanedIban.matches("[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}")) {
8 return false;
9 }
10
11 // 将前 4 个字符移到末尾
12 String rearranged = cleanedIban.substring(4) + cleanedIban.substring(0, 4);
13
14 // 将字母转换为数字
15 StringBuilder converted = new StringBuilder();
16 for (char c : rearranged.toCharArray()) {
17 if (Character.isLetter(c)) {
18 converted.append(c - 'A' + 10);
19 } else {
20 converted.append(c);
21 }
22 }
23
24 // 计算模 97
25 BigInteger numeric = new BigInteger(converted.toString());
26 return numeric.mod(BigInteger.valueOf(97)).intValue() == 1;
27 }
28
29 public static void main(String[] args) {
30 System.out.println(validateIban("DE89 3704 0044 0532 0130 00")); // true
31 System.out.println(validateIban("GB29 NWBK 6016 1331 9268 19")); // true
32 System.out.println(validateIban("DE89 3704 0044 0532 0130 01")); // false
33 }
34}
35
1function generateIban(countryCode) {
2 const countryFormats = {
3 'DE': { length: 22, bbanPattern: '8n10n' },
4 'GB': { length: 22, bbanPattern: '4a6n8n' },
5 'FR': { length: 27, bbanPattern: '5n5n11c2n' }
6 // 根据需要添加更多国家
7 };
8
9 if (!countryFormats[countryCode]) {
10 throw new Error(`国家代码 ${countryCode} 不受支持`);
11 }
12
13 // 根据国家格式生成随机 BBAN
14 let bban = '';
15 const pattern = countryFormats[countryCode].bbanPattern;
16 let i = 0;
17
18 while (i < pattern.length) {
19 const count = parseInt(pattern.substring(i + 1), 10);
20 const type = pattern[i];
21
22 if (type === 'n') {
23 // 生成数字字符
24 for (let j = 0; j < count; j++) {
25 bban += Math.floor(Math.random() * 10);
26 }
27 } else if (type === 'a') {
28 // 生成字母字符
29 for (let j = 0; j < count; j++) {
30 bban += String.fromCharCode(65 + Math.floor(Math.random() * 26));
31 }
32 } else if (type === 'c') {
33 // 生成字母数字字符
34 for (let j = 0; j < count; j++) {
35 const isLetter = Math.random() > 0.5;
36 if (isLetter) {
37 bban += String.fromCharCode(65 + Math.floor(Math.random() * 26));
38 } else {
39 bban += Math.floor(Math.random() * 10);
40 }
41 }
42 }
43
44 i += 2;
45 }
46
47 // 计算校验位
48 const checkDigits = calculateCheckDigits(countryCode, bban);
49
50 return countryCode + checkDigits + bban;
51}
52
53function calculateCheckDigits(countryCode, bban) {
54 // 使用 '00' 作为校验位创建初始 IBAN
55 const initialIban = countryCode + '00' + bban;
56
57 // 重新排列并将字母转换为数字
58 const rearranged = bban + countryCode + '00';
59 const converted = rearranged.split('').map(char => {
60 if (/[A-Z]/.test(char)) {
61 return (char.charCodeAt(0) - 55).toString();
62 }
63 return char;
64 }).join('');
65
66 // 计算 98 减去模 97
67 let remainder = 0;
68 for (let i = 0; i < converted.length; i++) {
69 remainder = (remainder * 10 + parseInt(converted[i], 10)) % 97;
70 }
71
72 const checkDigits = (98 - remainder).toString().padStart(2, '0');
73 return checkDigits;
74}
75
76// 示例用法
77console.log(generateIban('DE')); // 生成有效的德国 IBAN
78console.log(generateIban('GB')); // 生成有效的英国 IBAN
79
1import random
2import string
3
4def generate_iban(country_code):
5 country_formats = {
6 'DE': {'length': 22, 'bban_format': '8n10n'},
7 'GB': {'length': 22, 'bban_format': '4a6n8n'},
8 'FR': {'length': 27, 'bban_format': '5n5n11c2n'}
9 # 根据需要添加更多国家
10 }
11
12 if country_code not in country_formats:
13 raise ValueError(f"国家代码 {country_code} 不受支持")
14
15 # 根据国家格式生成随机 BBAN
16 bban = ''
17 format_str = country_formats[country_code]['bban_format']
18 i = 0
19
20 while i < len(format_str):
21 count = int(''.join(c for c in format_str[i+1:] if c.isdigit()))
22 type_char = format_str[i]
23
24 if type_char == 'n': # 数字
25 bban += ''.join(random.choices(string.digits, k=count))
26 elif type_char == 'a': # 字母
27 bban += ''.join(random.choices(string.ascii_uppercase, k=count))
28 elif type_char == 'c': # 字母数字
29 bban += ''.join(random.choices(string.ascii_uppercase + string.digits, k=count))
30
31 i += 1 + len(str(count))
32
33 # 计算校验位
34 check_digits = calculate_check_digits(country_code, bban)
35
36 return country_code + check_digits + bban
37
38def calculate_check_digits(country_code, bban):
39 # 创建用于校验位计算的字符串
40 check_string = bban + country_code + '00'
41
42 # 将字母转换为数字(A=10,B=11,...,Z=35)
43 numeric = ''
44 for char in check_string:
45 if char.isalpha():
46 numeric += str(ord(char.upper()) - 55)
47 else:
48 numeric += char
49
50 # 计算 98 减去模 97
51 remainder = int(numeric) % 97
52 check_digits = str(98 - remainder).zfill(2)
53
54 return check_digits
55
56# 示例用法
57print(generate_iban('DE')) # 生成有效的德国 IBAN
58print(generate_iban('GB')) # 生成有效的英国 IBAN
59
IBAN 生成器和验证工具为与国际银行标识符相关的测试和教育目的提供了一个简单而强大的解决方案。通过在用户友好的界面中提供生成和验证功能,它消除了复杂配置或第三方集成的需要。
无论您是在开发金融应用程序、测试支付系统,还是学习国际银行标准,这个工具都提供了一种简单的方式来处理 IBAN。全面的验证确保所有生成的 IBAN 在结构上都是合理的,并符合国际标准。
现在就尝试生成或验证一个 IBAN,以亲身体验该工具的功能吧!