Post

Replies

Boosts

Views

Activity

Reply to AES256 decryption in iOS - tutorial with swift
You can check README for AES examples: https://github.com/krzyzanowskim/CryptoSwift#aes the simplest form is this one-liner: let encrypted = try AES(key: key, blockMode: CBC(iv: iv), padding: .pkcs7).encrypt(plaintext) AES-256 requires 32 bytes long key. More complete example (AES-256-CBC), with a key generation out of password would be something along the lines. let password: [UInt8] = Array("s33krit".utf8) let salt: [UInt8] = Array("nacllcan".utf8) /* Generate a key from a `password`. Optional if you already have a key */ let key = try PKCS5.PBKDF2( 		password: password, 		salt: salt, 		iterations: 4096, 		keyLength: 32, /* AES-256 */ 		variant: .sha256 ).calculate() /* Generate random IV value. IV is public value. Either need to generate, or get it from elsewhere */ let iv = AES.randomIV(AES.blockSize) /* AES cryptor instance */ let aes = try AES(key: key, blockMode: CBC(iv: iv), padding: .pkcs7) /* Encrypt Data */ let inputData = Data() let encryptedBytes = try aes.encrypt(inputData.bytes) let encryptedData = Data(encryptedBytes) /* Decrypt Data */ let decryptedBytes = try aes.decrypt(encryptedData.bytes) let decryptedData = Data(decryptedBytes) beside README, there's playground you can take a look at CryptoSwift.playground - https://github.com/krzyzanowskim/CryptoSwift/blob/8ee88c7587be82a7c8ec0de4f882628a4f3768e5/CryptoSwift.playground/Contents.swift#L92
Nov ’20
Reply to NSPopupButton won't change value
According to Managing Pop-Up Buttons and Pull-Down Lists - https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MenuList/Articles/ManagingPopUpItems.html this is expected behavior Unlike popup lists, the title of a popup button displaying a pulldown list is not based on the currently selected item and thus remains fixed unless you change using the cell’s setTitle:method.
Aug ’20
Reply to updateLayer not called on layer backed NSView
I wanted to update it (after 5 years) that NSView.updateLayer() is still not called despite all the magic: override var wantsUpdateLayer: Bool { true } wantsLayer = true layerContentsRedrawPolicy = .onSetNeedsDisplay override func makeBackingLayer() -> CALayer { 		CATextLayer() } without custom makeBackingLayer, updateLayer() is called.
Jul ’20
Reply to How to create symlink in /usr/local/bin on macOS 10.15?
I'm browsing the forum with a hope I'll find a mention to `requestAuthorization` API and how to use it. Didn't find any yet. Do you mind to point me to one of many many existing questions with an answer to that maybe?eg. I see this https://forums.developer.apple.com/thread/127371 that says one strategy is to use `NSWorkspaceAuthorization` that is exactly what I'm trying to use, yet I'm failing.
Feb ’20