-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
374 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// DataExtension.swift | ||
// NoMADLoginAD | ||
// | ||
// Created by Josh Wisenbaker on 4/10/18. | ||
// Copyright © 2018 Orchard & Grove. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Data { | ||
|
||
init?(fromHexEncodedString string: String) { | ||
|
||
// Convert 0 ... 9, a ... f, A ...F to their decimal value, | ||
// return nil for all other input characters | ||
func decodeNibble(u: UInt16) -> UInt8? { | ||
switch(u) { | ||
case 0x30 ... 0x39: | ||
return UInt8(u - 0x30) | ||
case 0x41 ... 0x46: | ||
return UInt8(u - 0x41 + 10) | ||
case 0x61 ... 0x66: | ||
return UInt8(u - 0x61 + 10) | ||
default: | ||
return nil | ||
} | ||
} | ||
|
||
self.init(capacity: string.utf16.count/2) | ||
var even = true | ||
var byte: UInt8 = 0 | ||
for c in string.utf16 { | ||
guard let val = decodeNibble(u: c) else { return nil } | ||
if even { | ||
byte = val << 4 | ||
} else { | ||
byte += val | ||
self.append(byte) | ||
} | ||
even = !even | ||
} | ||
guard even else { return nil } | ||
} | ||
|
||
func hexEncodedString() -> String { | ||
return map { String(format: "%02hhx", $0) }.joined() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
// | ||
// TCSReturnWindow.h | ||
// Boot Runner | ||
// | ||
// Created by Tim Perfitt on 9/6/17. | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
// | ||
// TCSReturnWindow.m | ||
// Boot Runner | ||
// | ||
// Created by Tim Perfitt on 9/6/17. | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.