Files
Exodai-Academy-API/Sources/Extensions/RandomConfirmationCode.swift
2026-01-26 00:37:35 +01:00

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
}
}