Giter Club home page Giter Club logo

asn1swift's Introduction

Carthage compatible CocoaPods Compatible Swift Package Manager compatible Platform GitHub license

ASN1Swift provides a transparent interface to decode ASN.1 data structures. The ASN.1 Data Structure must be encoded using BER/DER Encoding Rules. To simplify encoding and decoding process ASN1Swift implement Encoder/Decoder protocol provided by swift foundation. In other words it works preciesly the same as JSONEncoder/JSONDecoder.

Installation

CocoaPods

To integrate ASN1Swift into your project using CocoaPods, specify it in your Podfile:

platform :ios, '13.0'

target 'YOUR_TARGET' do
use_frameworks!

pod 'ASN1Swift'
end

Then, run the following command:

$ pod install

In any swift file you'd like to use ASN1Swift, import the framework with import ASN1Swift.

Swift Package Manager

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/tikhop/ASN1Swift.git", .branch("master"))

Then, specify "ASN1Swift" as a dependency of the Target in which you wish to use ASN1Swift.

Lastly, run the following command:

swift package update

Carthage

Make the following entry in your Cartfile:

github "tikhop/ASN1Swift" 

Then run carthage update.

If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained over at Carthage.

Requirements

  • iOS 10.0+ / OSX 10.11+
  • Swift 5.2+

Example

Decoding InAppReceipt

let asn1Decoder = ASN1Decoder()
let r = try! asn1Decoder.decode(Receipt.self, from: Data(...))

struct Receipt: ASN1Decodable
{
    static var template: ASN1Template
    {
        return ASN1Template.universal(16).constructed()
    }

    var oid: ASN1SkippedField
    var signedData: SignedData

	enum CodingKeys: ASN1CodingKey
	{
        case oid
		case signedData

        var template: ASN1Template
        {
            switch self
            {
                case .oid:
                    return .universal(ASN1Identifier.Tag.objectIdentifier)
				case .signedData:
                    return SignedData.template
            }
        }
    }
}

....

Benchmarks

Library Decoding Time
ASN1Swift 0.154 seconds
filom/ASN1Decoder 1.032 seconds
asn1c ???
mrdepth/ASN1Decoder ???

License

ASN1Swift is released under a BSD-3-Clause. See LICENSE for more information.

asn1swift's People

Contributors

holtwick avatar tikhop avatar

Watchers

 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.