added iOS source code
[wl-app.git] / iOS / Pods / OAuthSwift / Sources / Utils.swift
diff --git a/iOS/Pods/OAuthSwift/Sources/Utils.swift b/iOS/Pods/OAuthSwift/Sources/Utils.swift
new file mode 100644 (file)
index 0000000..8d13615
--- /dev/null
@@ -0,0 +1,23 @@
+//
+//  Utils.swift
+//  OAuthSwift
+//
+//  Created by Dongri Jin on 1/28/15.
+//  Copyright (c) 2015 Dongri Jin. All rights reserved.
+//
+
+import Foundation
+
+public func generateState(withLength len: Int) -> String {
+    let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+    let length = UInt32(letters.count)
+
+    var randomString = ""
+    for _ in 0..<len {
+        let rand = arc4random_uniform(length)
+        let idx = letters.index(letters.startIndex, offsetBy: Int(rand))
+        let letter = letters[idx]
+        randomString += String(letter)
+    }
+    return randomString
+}