Skip to content

Instantly share code, notes, and snippets.

@jverkoey
Created February 6, 2019 18:33
Show Gist options
  • Save jverkoey/64aba8d1902f1fd115d69d79670db119 to your computer and use it in GitHub Desktop.
Save jverkoey/64aba8d1902f1fd115d69d79670db119 to your computer and use it in GitHub Desktop.
Data+xored.swift
import Foundation
extension Data {
/**
Returns the result of xor'ing self with the given Data.
*/
public func xored(with rhs: Data) -> Data {
return Data(zip(self, rhs).map { $0 ^ $1 })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment