24 lines
516 B
Swift
24 lines
516 B
Swift
//
|
|
// RandomConfirmationCode.swift
|
|
// ExodaiAcademy
|
|
//
|
|
// Created by Exodai on 23/01/2026.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension String {
|
|
static func randomConfirmationCode(length: Int = 8) -> String {
|
|
let characters = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
|
var result = ""
|
|
result.reserveCapacity(length)
|
|
|
|
for _ in 0..<length {
|
|
let index = Int.random(in: 0..<characters.count)
|
|
result.append(characters[index])
|
|
}
|
|
|
|
return result
|
|
}
|
|
}
|