2018-10-28 10:55:42 -07:00
# MnemonicKit [![Build Status](https://travis-ci.org/keefertaylor/MnemonicKit.svg?branch=master)](https://travis-ci.org/keefertaylor/MnemonicKit) [![codecov](https://codecov.io/gh/keefertaylor/MnemonicKit/branch/master/graph/badge.svg)](https://codecov.io/gh/keefertaylor/MnemonicKit)
2018-10-28 13:34:30 -07:00
An implementation of BIP39 in Swift. MnemonicKit supports both English and Chinese mnemonics.
2017-07-25 20:30:03 -07:00
2018-10-28 10:55:42 -07:00
This library is originally forked from CKMnemonic: https://github.com/CikeQiu/CKMnemonic. Modifications are made for non-throwing APIs and support on OSX as well as iOS. Credit for most of this work is given to work_cocody@hotmail.com, qiuhongyang@askcoin.org.
2017-07-25 20:30:03 -07:00
## Installation
2018-10-28 10:55:42 -07:00
### CocoaPods
TezosKit supports installation via CocoaPods. You can depened on MnemonicKit by adding the following to your Podfile:
2017-07-25 20:30:03 -07:00
```
2018-10-28 14:18:00 -07:00
pod "MnemonicKit"
2018-10-28 10:55:42 -07:00
```
## Usage
2018-10-28 13:34:30 -07:00
### Generate a Mnemonic
```swift
let englishMnemonic = Mnemonic.generateMnemonic(strength: 64, language: .english)
let chineseMnemonic = Mnemonic.generateMnemonic(strength: 128, language: .chinese)
```
### Generate a Mnemonic from a Hex Represetation
```swift
let hexRepresentation: String = ...
let mnemonic = Mnemonic.mnemonicString(from: hexRepresentation)
print("Mnemonic: \(mnemonic)\nFrom hex string: \(hexRepresentation)")
```
### Generate a Seed String
```swift
let englishMnemonic = Mnemonic.generateMnemonic(strength: 64, language: .english)
let passphrase: String = ...
let deterministicSeedString = Mnemonic.deterministicSeedString(from: mnemonicString,
passphrase: passphrase,
language: .english)
print("Deterministic Seed String: \(deterministicSeedString)")
```
2017-07-25 20:30:03 -07:00
2018-10-28 10:55:42 -07:00
## Contributions
2017-07-25 20:30:03 -07:00
2018-10-28 10:55:42 -07:00
I am happy to accept pull requests. If anyone is able to reach the original authors of CKMnemonic, I am happy to merge this library upstream with them.
2017-07-25 20:30:03 -07:00
## License
2018-10-28 10:55:42 -07:00
MIT