Initial commit
This commit is contained in:
23
Sources/Extensions/RandomConfirmationCode.swift
Normal file
23
Sources/Extensions/RandomConfirmationCode.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user