GithubHelp home page GithubHelp logo

mlachmish / bit Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 0.0 114 KB

Super light Bit operation library in Swift.

Home Page: http://www.thebigfatninja.xyz

License: MIT License

Ruby 4.02% Objective-C 2.72% Swift 93.26%
swift bitwise-arithmetic

bit's Introduction

Bit

Language Platform MIT licensed
Build Status Code Quality Code Coverage
CocoaPods Carthage


Super light Bit operation library in Swift.

FeaturesUsageInstallationDocumentationAuthorLicense

Features

Full support of UInt8, UInt32 and UInt64.

  • Byte accesors
  • Bitwise arithmetic
  • Representation convertors

Usage

Accesors Functions

    let val1 = 0xA5C964F2 as UInt32
    val1.firstByte  //0xF2
    val1.secondByte //0x64
    val1.thirdByte  //0xC9
    val1.fourthByte //0xA5

Bitwise arithmetic

    let val1 = 0x00000001 as UInt32
    val1.rotateLeft(0x00000002)     //0x00000004
    val1.rotateRight(0x00000002)    //0x40000000
    val1.reverseBytes()             //0x01000000

Representation convertors

    Representations.toUInt8Array(64)    //[UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x40)]
    
    Representations.mergeToUInt32Array([UInt8(0x01), UInt8(0x01), UInt8(0x01), UInt8(0x01),UInt8(0x01), UInt8(0x01), UInt8(0x01), UInt8(0x01)])       //UInt32(0x01010101), UInt32(0x01010101)]
    
    Representations.toHexadecimalString([UInt8(0x01), UInt8(0x01), UInt8(0x01), UInt8(0x01)])   //"01010101"

Installation

Compatibility

  • OS X 10.9+ / iOS 8.0+ / watchOS 2.0 / tvOS 9.0

  • Xcode 7.1+, Swift 2.1+

Install Using CocoaPods

CocoaPods is a centralized dependency manager for Objective-C and Swift. Go here to learn more.

  1. Add the project to your Podfile.

    use_frameworks!
    
    pod 'Bit'
  2. Run pod install and open the .xcworkspace file to launch Xcode.

  3. Import the Cryptography framework.

    import Bit

Install Using Carthage

Carthage is a decentralized dependency manager for Objective-C and Swift.

  1. Add the project to your Cartfile.

    github "mlachmish/Bit"
    
  2. Run carthage update and follow the additional steps in order to add Cryptography to your project.

  3. Import the Cryptography framework.

    import Bit

###Swift Package Manager You can use Swift Package Manager and specify dependency in Package.swift by adding this:

.Package(url: "https://github.com/mlachmish/Bit.git", majorVersion: 0)

Manually

Download and drop /Bit folder in your project.

Author

Matan Lachmish a.k.a The Big Fat Ninja The Big Fat Ninja
https://thebigfatninja.xyz

attribution

Icon made by Freepik from www.flaticon.com

License

Bit is available under the MIT license. See the LICENSE file for more info.

bit's People

Contributors

mlachmish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.