Posts

Post marked as solved
13 Replies
0 Views
Thanks for your answer.Sorry im new to OSX and SWIFT.In windows when the `X` is clicked the Application closes.I thought the application did not close as i was debugging in XCODE.What i want to achieve is show a Trial notification to the user.When he/she tries to quit the application.ie:You are using a trial version of my product ........
Post not yet marked as solved
8 Replies
0 Views
Actually i found a way to encrypt strings that support PHP and SWIFThttp://sketchytech.blogspot.in/2016/02/resurrecting-commoncrypto-in-swift-for.htmlThis works fine.But im wondering if this will effect the compatibility of the application ie: using bridging and Common Crypto.I'm currently running XCode 8 on Sierra.Will the resulting application work on older versions of OSX.I want to maximize compatibilty.------------------------------------------------------------------------------------------------The domain has HTTPS Cerficate and is set use HTTPS by default.How can i modify HTTP POST to use only HTTPS.Is man in the middle attack possible ie: Make Spoofed Server and may be send 'Valid' for all activation requests.Please advice.
Post marked as solved
13 Replies
0 Views
Its the Close button on the Top Left corner for OSX Application window.
Post not yet marked as solved
8 Replies
0 Views
Thanks a lot for the detailed answer 🙂 i really appreciate it.What im trying to acheive is-Send some licensing data to the server (php script) via HTTP POST.The server verifies the licensing information and replies whether the license is valid.I intend to secure the communication between the client(OSX App) and the server by encrypting the data using a common cryptographic scheme.Currently what im using is Common Crypto -I have referred this answer https://stackoverflow.com/a/45507302/848968and added the Bridging Headerextension String { func aesEncrypt(key:String, iv:String, options:Int = kCCOptionPKCS7Padding) -> String? { if let keyData = key.data(using: String.Encoding.utf8), let data = self.data(using: String.Encoding.utf8), let cryptData = NSMutableData(length: Int((data.count)) + kCCBlockSizeAES128) { let keyLength = size_t(kCCKeySizeAES128) let operation: CCOperation = UInt32(kCCEncrypt) let algoritm: CCAlgorithm = UInt32(kCCAlgorithmAES128) let options: CCOptions = UInt32(options) var numBytesEncrypted :size_t = 0 let cryptStatus = CCCrypt(operation, algoritm, options, (keyData as NSData).bytes, keyLength, iv, (data as NSData).bytes, data.count, cryptData.mutableBytes, cryptData.length, &numBytesEncrypted) if UInt32(cryptStatus) == UInt32(kCCSuccess) { cryptData.length = Int(numBytesEncrypted) let base64cryptString = cryptData.base64EncodedString(options: .lineLength64Characters) return base64cryptString } else { return nil } } return nil } func aesDecrypt(key:String, iv:String, options:Int = kCCOptionPKCS7Padding) -> String? { if let keyData = key.data(using: String.Encoding.utf8), let data = NSData(base64Encoded: self, options: .ignoreUnknownCharacters), let cryptData = NSMutableData(length: Int((data.length)) + kCCBlockSizeAES128) { let keyLength = size_t(kCCKeySizeAES128) let operation: CCOperation = UInt32(kCCDecrypt) let algoritm: CCAlgorithm = UInt32(kCCAlgorithmAES128) let options: CCOptions = UInt32(options) var numBytesEncrypted :size_t = 0 let cryptStatus = CCCrypt(operation, algoritm, options, (keyData as NSData).bytes, keyLength, iv, data.bytes, data.length, cryptData.mutableBytes, cryptData.length, &numBytesEncrypted) if UInt32(cryptStatus) == UInt32(kCCSuccess) { cryptData.length = Int(numBytesEncrypted) let unencryptedMessage = String(data: cryptData as Data, encoding:String.Encoding.utf8) return unencryptedMessage } else { return nil } } return nil } }The Data is sent to the server using the following codevar request = var request = URLRequest(url: URL(string: "http://www.example.com/test.php")!) request.httpMethod = "POST" let akey:String = txt_key.stringValue; let email:String = txt_email.stringValue let VAL:String="test" var data="blah" let postString = data request.httpBody = postString.data(using: .utf8) let task = URLSession.shared.dataTask(with: request) { data, response, error in guard let data = data, error == nil else { / print("error=\(error)") return } if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 { / print("statusCode should be 200, but is \(httpStatus.statusCode)") print("response = \(response)") } let responseString = String(data: data, encoding: .utf8) print(responseString) } task.resume()All these stuff works .. But im having a hard time finding an Encyption method that is cross compatible with PHPSo far i have triedmcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key256, $text, MCRYPT_MODE_CBC, $iv128);How should i go forward,Please advice 🙂
Post not yet marked as solved
5 Replies
0 Views
Please see the code which i have updated.Is this correct?extension NSImage { func resizeImage(width: CGFloat, _ height: CGFloat,owidth:CGFloat,oheight:CGFloat) -> NSImage { let theWidthScaleFactor = width / owidth let theHeightScaleFactor = height / oheight let theScaleFactor = min(theWidthScaleFactor, theHeightScaleFactor) let theWidth = width * theScaleFactor let theHeight = height * theScaleFactor let img = NSImage(size: CGSize(width:theWidth, height:theHeight)) img.lockFocus() let ctx = NSGraphicsContext.current() ctx?.imageInterpolation = .high self.draw(in: NSMakeRect(0, 0, width, height), from: NSMakeRect(0, 0, size.width, size.height), operation: .copy, fraction: 1) img.unlockFocus() return img } }
Post not yet marked as solved
5 Replies
0 Views
okay.thanks... will check it out.
Post not yet marked as solved
5 Replies
0 Views
Thanks.But i'm new to the language.In c# we do something like this stackoverflow.com/a/2001692/848968Can you please update the extension.
Post marked as solved
2 Replies
0 Views
Thanks ... followed the second approach already 🙂