Impressia/Vernissage/Extensions/String+Random.swift

15 lines
408 B
Swift
Raw Normal View History

2023-02-21 21:54:10 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
2023-03-28 10:35:38 +02:00
// Licensed under the Apache License 2.0.
2023-02-21 21:54:10 +01:00
//
2023-02-21 21:54:10 +01:00
import Foundation
extension String {
static func randomString(length: Int) -> String {
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
return String((0..<length).map { _ in letters.randomElement()! })
2023-02-21 21:54:10 +01:00
}
}