UInt64+Extension.swift 565 B

12345678910111213141516171819
  1. //
  2. // UInt64Extension.swift
  3. // CryptoSwift
  4. //
  5. // Created by Marcin Krzyzanowski on 02/09/14.
  6. // Copyright (c) 2014 Marcin Krzyzanowski. All rights reserved.
  7. //
  8. /** array of bytes */
  9. extension UInt64 {
  10. public func bytes(totalBytes: Int = MemoryLayout<UInt64>.size) -> Array<UInt8> {
  11. return arrayOfBytes(value: self, length: totalBytes)
  12. }
  13. /** Int with array bytes (little-endian) */
  14. public static func with<T: Collection>(_ bytes: T) -> UInt64 where T.Iterator.Element == UInt8, T.Index == Int {
  15. return bytes.toInteger()
  16. }
  17. }