Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Alamofire.request(.POST, "http://sample.com/api/login", parameters: param)
- .responseJSON { (responce) in
- guard let object = responce.result.value else {
- return
- }
- let json = JSON(object)
- let aaa = json["result"].string!
- let bbb = aaa.dataUsingEncoding(NSUTF8StringEncoding)
- let ccc = bbb?.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
- let ddd = ccc!.dataUsingEncoding(NSUTF8StringEncoding)
- let eee = dataTool.decrypt(ddd!)
- print(ddd)
- }
- public func decrypt(encryptData: NSData) -> NSString? {
- let privKey = findKey("com.sample.Test.private")
- let cipherBuffer = UnsafePointer<UInt8>(encryptData.bytes)
- var plaintextBufferSize = SecKeyGetBlockSize(privKey!)
- var plaintextBuffer = [UInt8](count:Int(plaintextBufferSize), repeatedValue:0)
- let status = SecKeyDecrypt(privKey!,
- SecPadding.PKCS1,
- cipherBuffer,
- encryptData.length,
- &plaintextBuffer,
- &plaintextBufferSize)
- if (status != errSecSuccess) {
- return nil
- }
- return NSString(bytes: UnsafePointer<Void>(plaintextBuffer), length:Int(plaintextBufferSize), encoding: NSUTF8StringEncoding)
- }
Add Comment
Please, Sign In to add comment