@@ -2,12 +2,12 @@ import Foundation
2
2
3
3
/// URI Safe base64 encode
4
4
func base64encode( _ input: Data ) -> String {
5
- let data = input. base64EncodedData ( options : NSData . Base64EncodingOptions ( rawValue : 0 ) )
5
+ let data = input. base64EncodedData ( )
6
6
let string = String ( data: data, encoding: . utf8) !
7
7
return string
8
- . replacingOccurrences ( of: " + " , with: " - " , options : NSString . CompareOptions ( rawValue : 0 ) , range : nil )
9
- . replacingOccurrences ( of: " / " , with: " _ " , options : NSString . CompareOptions ( rawValue : 0 ) , range : nil )
10
- . replacingOccurrences ( of: " = " , with: " " , options : NSString . CompareOptions ( rawValue : 0 ) , range : nil )
8
+ . replacingOccurrences ( of: " + " , with: " - " )
9
+ . replacingOccurrences ( of: " / " , with: " _ " )
10
+ . replacingOccurrences ( of: " = " , with: " " )
11
11
}
12
12
13
13
/// URI Safe base64 decode
@@ -20,8 +20,8 @@ func base64decode(_ input: String) -> Data? {
20
20
ending = String ( repeating: " = " , count: amount)
21
21
}
22
22
23
- let base64 = input. replacingOccurrences ( of: " - " , with: " + " , options : NSString . CompareOptions ( rawValue : 0 ) , range : nil )
24
- . replacingOccurrences ( of: " _ " , with: " / " , options : NSString . CompareOptions ( rawValue : 0 ) , range : nil ) + ending
23
+ let base64 = input. replacingOccurrences ( of: " - " , with: " + " )
24
+ . replacingOccurrences ( of: " _ " , with: " / " ) + ending
25
25
26
- return Data ( base64Encoded: base64, options : NSData . Base64DecodingOptions ( rawValue : 0 ) )
26
+ return Data ( base64Encoded: base64)
27
27
}
0 commit comments