UInt64+Extension.swift 479 B

123456789101112131415161718
  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. init<T: Collection>(bytes: T) where T.Iterator.Element == UInt8, T.Index == Int {
  11. self = bytes.toInteger()
  12. }
  13. func bytes(totalBytes: Int = MemoryLayout<UInt64>.size) -> Array<UInt8> {
  14. return arrayOfBytes(value: self, length: totalBytes)
  15. }
  16. }