大量代码。
This commit is contained in:
27
ShadowsocksX-NG/Utils.swift
Normal file
27
ShadowsocksX-NG/Utils.swift
Normal file
@ -0,0 +1,27 @@
|
||||
//
|
||||
// Utils.swift
|
||||
// ShadowsocksX-NG
|
||||
//
|
||||
// Created by 邱宇舟 on 16/6/7.
|
||||
// Copyright © 2016年 qiuyuzhou. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
extension String {
|
||||
var localized: String {
|
||||
return NSLocalizedString(self, tableName: nil, bundle: NSBundle.mainBundle(), value: "", comment: "")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension NSData {
|
||||
func sha1() -> String {
|
||||
let data = self
|
||||
var digest = [UInt8](count:Int(CC_SHA1_DIGEST_LENGTH), repeatedValue: 0)
|
||||
CC_SHA1(data.bytes, CC_LONG(data.length), &digest)
|
||||
let hexBytes = digest.map { String(format: "%02hhx", $0) }
|
||||
return hexBytes.joinWithSeparator("")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user