/**
IntExtensions.swift
Convert an arbitrary length byte array into a Swift Int
<https://gist.github.com/tannernelson/e720877bf7700138eb99>
*/
extension Int {
static func fromByteArray(bytes: [UInt8]) -> Int {
var int = 0
for (offset, byte) in enumerate(bytes) {
let factor: Double = Double(bytes.count) - (Double(offset) + 1);
let size: Double = 256
int += Int(byte) * Int(pow(size, factor))
}
return int
}
}