UInt64Extension.swift 634 B

12345678910111213141516171819202122232425
  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. import Foundation
  9. /** array of bytes */
  10. extension UInt64 {
  11. public func bytes(totalBytes: Int = sizeof(UInt64)) -> [UInt8] {
  12. return arrayOfBytes(self, length: totalBytes)
  13. }
  14. public static func withBytes(bytes: ArraySlice<UInt8>) -> UInt64 {
  15. return UInt64.withBytes(Array(bytes))
  16. }
  17. /** Int with array bytes (little-endian) */
  18. public static func withBytes(bytes: [UInt8]) -> UInt64 {
  19. return integerWithBytes(bytes)
  20. }
  21. }