Skip to content

Commit 86b273c

Browse files
committed
Update demo
1 parent 729a831 commit 86b273c

File tree

10 files changed

+79
-726
lines changed

10 files changed

+79
-726
lines changed

Example-iOS/Argon2ViewController.swift

Lines changed: 0 additions & 75 deletions
This file was deleted.

Example-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
"idiom" : "ipad",
8585
"size" : "83.5x83.5",
8686
"scale" : "2x"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"size" : "1024x1024",
91+
"scale" : "1x"
8792
}
8893
],
8994
"info" : {

Example-iOS/Base.lproj/Main.storyboard

Lines changed: 16 additions & 440 deletions
Large diffs are not rendered by default.

Example-iOS/MD2ViewController.swift

Lines changed: 0 additions & 36 deletions
This file was deleted.

Example-iOS/MD4ViewController.swift

Lines changed: 0 additions & 36 deletions
This file was deleted.

Example-iOS/MD5ViewController.swift

Lines changed: 0 additions & 36 deletions
This file was deleted.

Example-iOS/MD6ViewController.swift

Lines changed: 0 additions & 36 deletions
This file was deleted.

Example-iOS/ResultViewController.swift

Lines changed: 0 additions & 43 deletions
This file was deleted.

Example-iOS/RootViewController.swift

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//
2+
// RootViewController.swift
3+
// Example-iOS
4+
//
5+
// Created by Kcat on 2017/12/25.
6+
// Copyright © 2017年 imkcat. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import CatCrypto
11+
12+
class RootViewController: UIViewController {
13+
14+
let hashAndEncryptQueue = DispatchQueue(label: "com.CatCrypto.HashAndEncryptQueue")
15+
let sourceString: String = "CatCrypto"
16+
17+
let hashCryptos: Array<Hashing> = [CatMD2Crypto(),
18+
CatMD4Crypto(),
19+
CatMD5Crypto(),
20+
CatMD6Crypto(),
21+
CatArgon2Crypto()]
22+
23+
override func viewDidLoad() {
24+
super.viewDidLoad()
25+
}
26+
27+
override func didReceiveMemoryWarning() {
28+
super.didReceiveMemoryWarning()
29+
}
30+
31+
@IBAction func hashAndEncrypt(_ sender: Any) {
32+
let infoDict = Bundle(identifier: "com.imkcat.CatCrypto-iOS")?.infoDictionary
33+
let version = infoDict!["CFBundleShortVersionString"] as? String
34+
print("CatCrypto, Version: " + version! + "\n")
35+
for hashCrypto in hashCryptos {
36+
let hashTimer = DispatchSource.makeTimerSource(queue: DispatchQueue.global())
37+
hashTimer.schedule(deadline: DispatchTime.now(), repeating: .milliseconds(1))
38+
var timeCost = 0.000
39+
hashTimer.setEventHandler(handler: {
40+
timeCost += 0.001
41+
})
42+
let hashWorkItem = DispatchWorkItem(block: {
43+
hashTimer.resume()
44+
print("Crypto name: " + String(describing: hashCrypto.self))
45+
let hashResult = hashCrypto.hash(password: self.sourceString)
46+
print("Result: " + (hashResult.error == nil ? hashResult.value! : hashResult.error!.errorDescription!))
47+
hashTimer.cancel()
48+
print("Cost: " + String(format: "%0.3f", timeCost) + "s\n")
49+
})
50+
hashAndEncryptQueue.async(execute: hashWorkItem)
51+
}
52+
}
53+
54+
}

0 commit comments

Comments
 (0)