aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Extensions/String+Base64.swift
blob: b94dc88f666233f94c45dd57f7d68d304c1d5b2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//
//  String+Base64.swift
//  WireGuard
//
//  Created by Eric Kuck on 8/15/18.
//  Copyright © 2018 WireGuard LLC. All rights reserved.
//

import Foundation

extension String {

    func isBase64() -> Bool {
        let base64Predicate = NSPredicate(format: "SELF MATCHES %@", "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$")
        return base64Predicate.evaluate(with: self)
    }

}