2021-09-03 02:50:40 +02:00
|
|
|
//
|
|
|
|
|
// PasswordManager.swift
|
|
|
|
|
// pass
|
|
|
|
|
//
|
|
|
|
|
// Created by Mingshen Sun on 17/1/2021.
|
|
|
|
|
// Copyright © 2021 Bob Sun. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
2021-01-17 19:49:05 -08:00
|
|
|
import passKit
|
|
|
|
|
import SVProgressHUD
|
2021-01-31 13:17:37 +01:00
|
|
|
import UIKit
|
2021-01-17 19:49:05 -08:00
|
|
|
|
|
|
|
|
class PasswordManager {
|
2021-09-20 09:50:05 +02:00
|
|
|
private let viewController: UIViewController
|
2021-01-17 19:49:05 -08:00
|
|
|
|
|
|
|
|
init(viewController: UIViewController) {
|
|
|
|
|
self.viewController = viewController
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func providePasswordPasteboard(with passwordPath: String) {
|
|
|
|
|
decryptPassword(in: viewController, with: passwordPath) { password in
|
|
|
|
|
SecurePasteboard.shared.copy(textToCopy: password.password)
|
|
|
|
|
SVProgressHUD.setDefaultMaskType(.black)
|
|
|
|
|
SVProgressHUD.setDefaultStyle(.dark)
|
|
|
|
|
SVProgressHUD.showSuccess(withStatus: "PasswordCopiedToPasteboard.".localize())
|
|
|
|
|
SVProgressHUD.dismiss(withDelay: 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func addPassword(with password: Password) {
|
|
|
|
|
encryptPassword(in: viewController, with: password) {
|
|
|
|
|
SVProgressHUD.setDefaultMaskType(.black)
|
|
|
|
|
SVProgressHUD.setDefaultStyle(.light)
|
|
|
|
|
SVProgressHUD.showSuccess(withStatus: "Done".localize())
|
|
|
|
|
SVProgressHUD.dismiss(withDelay: 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|