MnemonicSwift/README.md

71 lines
2.0 KiB
Markdown
Raw Normal View History

2020-06-08 14:17:51 -07:00
# MnemonicSwift
2020-06-12 14:32:47 -07:00
[![Build Status](https://travis-ci.org/zcash-hackworks/MnemonicSwift.svg?branch=master)](https://travis-ci.org/zcash-hackworks/MnemonicSwift)
2020-06-08 14:17:51 -07:00
An implementation of BIP39 in Swift. MnemonicSwift supports both English and Chinese mnemonics.
2021-12-13 06:08:01 -08:00
This library is a fork of [MnemonicKit](https://github.com/keefertaylor/MnemonicKit). This fork provides provides support for BIP39 using Crypto.
2017-07-25 20:30:03 -07:00
2020-09-09 11:25:36 -07:00
**NOTE to 1.0.0 users**: If you are using 1.0.0 in your project, we no longer maintain that version. Upgrade to 2.0.0 immediately.
2017-07-25 20:30:03 -07:00
## Installation
2018-10-28 10:55:42 -07:00
### CocoaPods
2020-06-12 16:56:18 -07:00
MnemonicSwift supports installation via CocoaPods. You can depened on MnemonicSwift by adding the following to your Podfile:
2017-07-25 20:30:03 -07:00
```
2020-06-08 14:17:51 -07:00
pod "MnemonicSwift"
2018-10-28 10:55:42 -07:00
```
2019-01-03 23:54:03 -08:00
#### Carthage
If you use [Carthage](https://github.com/Carthage/Carthage) to manage your dependencies, simply add
2020-06-12 16:56:18 -07:00
MnemonicSwift to your `Cartfile`:
2019-01-03 23:54:03 -08:00
```
2020-06-08 14:17:51 -07:00
github "zcash-hackworks/MnemonicSwift"
2019-01-03 23:54:03 -08:00
```
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)
```
2018-10-28 14:18:30 -07:00
### Generate a Mnemonic from a Hex Representation
2018-10-28 13:34:30 -07:00
```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
2019-10-27 20:20:33 -07:00
To get set up:
```shell
$ brew install xcodegen # if you don't already have it
$ xcodegen generate # Generate an XCode project from Project.yml
2020-06-12 16:56:18 -07:00
$ open MnemonicSwift.xcodeproj
2019-10-27 20:20:33 -07:00
```
2017-07-25 20:30:03 -07:00
## License
2018-10-28 10:55:42 -07:00
MIT