func splitEncryptionKey()

in sdk/communication/AzureCommunicationChat/Source/NotificationUtils/CryptoUtils.swift [159:179]


func splitEncryptionKey(encryptionKey: String) throws -> [String] {
    guard var data = Data(base64Encoded: encryptionKey, options: .ignoreUnknownCharacters) else {
        throw AzureError
            .client("Failed to convert base64Encoded string into Data format.")
    }
    var aesArr: [UInt8] = .init(repeating: 0, count: 32)
    var authArr: [UInt8] = .init(repeating: 0, count: 32)

    for idx in 0 ..< 64 {
        if idx < 32 {
            aesArr[idx] = data.remove(at: 0)
        } else {
            authArr[idx - 32] = data.remove(at: 0)
        }
    }

    let aesKey = Data(aesArr).base64EncodedString()
    let authKey = Data(authArr).base64EncodedString()

    return [aesKey, authKey]
}