SwiftMultihash
Swift implementation of multihash
Table of Contents
Install
Carthage
Add the following to your Cartfile:
github "multihash/SwiftMultihash"
Then, in the root of your project, type:
carthage update --platform Mac
If you get the error 'Project "VarInt.xcodeproj" has no shared schemes'
Make sure your scheme is marked shared. For more details see here
- from the Multihash root type
carthage build
You will then need to add frameworks to your own Xcode project:
-
Select your target's
Build Phases
tab. -
Select the
Link Binary With Libraries
, click the+
and thenAdd Other...
buttons. -
Navigate to the Carthage/Build/Mac directory in your project root and select the SwiftMultihash.framework, SwiftBase58.framework and SwiftHex.framework.
-
In case of a code signing error, select the target's Build Settings tab make sure the "Code Signing Identity" is either a valid identity or "Don't Code Sign".
For more information on how to install via Carthage see the README
Requirements
- Swift 3
Usage
import SwiftMultihash
import SwiftHex
func test() {
if let buffer = SwiftHex.decodeString("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33") {
let (multihashBuffer,_) = SwiftMultihash.encodeName(buffer, "sha1")
if let mhb = multihashBuffer {
var multihashHex = SwiftHex.encodeToString(mhb)
println("Hex: \(multihashHex)")
let (object, _) = SwiftMultihash.decode(mhb)
if let obj = object {
multihashHex = SwiftHex.encodeToString(obj.digest)
println(String(format: "obj: %@ 0x%X %d %@\n", obj.name!, obj.code, obj.length, multihashHex))
}
}
}
}
Maintainers
Captain: @NeoTeo.
Contribute
Contributions are welcome! Check out the issues.
Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to Multiformats are subject to the IPFS Code of Conduct.
Small note: If editing the README, note that this README should be standard-readme compatible.
License
MIT © 2015 Matteo Sartori