using CryptoSwift for sha1, getting rid of a few warnings

This commit is contained in:
Johan Degraeve 2019-12-14 21:43:58 +01:00
parent ceb5e797e8
commit 918edd93b4
4 changed files with 12 additions and 12 deletions

View File

@ -11,4 +11,7 @@ target 'xdrip' do
use_frameworks!
pod 'SwiftCharts', '~> 0.6.5'
use_frameworks!
pod 'CryptoSwift', '~> 1.0'
end

View File

@ -1,14 +1,18 @@
PODS:
- ActionClosurable (1.2.0)
- CryptoSwift (1.2.0)
- SwiftCharts (0.6.5)
DEPENDENCIES:
- ActionClosurable (from `https://github.com/takasek/ActionClosurable.git`)
- CryptoSwift (~> 1.0)
- SwiftCharts (~> 0.6.5)
SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
- SwiftCharts
trunk:
- CryptoSwift
EXTERNAL SOURCES:
ActionClosurable:
@ -21,8 +25,9 @@ CHECKOUT OPTIONS:
SPEC CHECKSUMS:
ActionClosurable: ff826688551b031c6bd936cb4928ebf63571893a
CryptoSwift: 40e374e45291d8dceedcb0d6184da94533eaabdf
SwiftCharts: 2e755ea292f0b87d3e4b2c1eb5afc080a20cdc15
PODFILE CHECKSUM: 9dee35b1fb05f0e2bf7a6c38eb6213635af56273
PODFILE CHECKSUM: ce8e284b6b6051e2df3dac5666c212b8cf16b9f0
COCOAPODS: 1.8.4

View File

@ -1,5 +1,5 @@
import UIKit
import CommonCrypto
import CryptoSwift
extension String {
//https://stackoverflow.com/questions/39677330/how-does-string-substring-work-in-swift
@ -68,13 +68,8 @@ extension String {
extension String {
func sha1() -> String {
let data = Data(self.utf8)
var digest = [UInt8](repeating: 0, count:Int(CC_SHA1_DIGEST_LENGTH))
data.withUnsafeBytes {
_ = CC_SHA1($0, CC_LONG(data.count), &digest)
}
let hexBytes = digest.map { String(format: "%02hhx", $0) }
return hexBytes.joined()
// sha1() here is a function in CryptoSwift Library
return Data(self.utf8).sha1().hexEncodedString()
}
}

View File

@ -145,9 +145,6 @@ struct SettingsViewM5StackWiFiSettingsViewModel: SettingsViewModelProtocol {
text = UserDefaults.standard.m5StackWiFiPassword3
actionHandler = {(password:String) in UserDefaults.standard.m5StackWiFiPassword3 = password.toNilIfLength0()}
titlePart = Texts_Common.password
default:
// keep the default even if it gives a warning, just in case we add cases which are not processed here but which need processing
fatalError("createSettingsSelectedRowActionForWifiName, invalid wifiNumber")
}
return SettingsSelectedRowAction.askText(title: Texts_Common.WiFi + " " + titlePart + " " + wifiNumberAsInt!.description, message: nil, keyboardType: .default, text: text, placeHolder: "", actionTitle: nil, cancelTitle: nil, actionHandler: actionHandler!, cancelHandler: nil)