IKCryptoKeyboard 1.0.3

IKCryptoKeyboard 1.0.3

IKCryptoTextEdit 维护。



  • 作者:
  • leibniz55

IKCryptoKeyboard

CI Status Version License Platform

演示

英文/韩文键盘

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

要求

  • Swift 4.0
  • ios 9.3

依赖项

安装

IKCryptoKeyboard可通过CocoaPods访问。要安装它,只需将以下行添加到您的Podfile中

pod 'IKCryptoKeyboard'

用法

extension ViewController: UITextFieldDelegate{

  func textFieldDidBeginEditing(_ textField: UITextField) {
    _ = textField.resignFirstResponder()
    
    let vc = IKCryptoKeyBoardViewController()
    vc.delegate = self
    
    self.present(vc, animated: true)
  }
}

extension ViewController: IKCryptoKeyBoardViewControllerDelegate {
  // get encrypted data from IKCryptoKeyBoardViewController
  func didEncrypted(plain: String, encryptedData: Array<UInt8>) {
    // `plain` is replaced password as "aaaaa..."
    // `encryptedData` is encrypted password
  }
  
  // for debug
  func didDecrypted(decryptedData: Array<UInt8>) {
  // `decryptedData` is password
  }
}

自定义

规则。

如果你遵守规则,你就可以使用所有语言的键盘。

let vc = IKCryptoKeyBoardViewController()
var configure = IKCryptoKeyBoardConfigure()
vc.configure = configure


public struct IKCryptoKeyBoardConfigure {
  
  public struct Color {
    public var touchedKey = UIColor(red:0.20, green:0.39, blue:0.73, alpha:1.0)
    public var defaultKey = UIColor(red:0.00, green:0.19, blue:0.53, alpha:1.0)
    public var functionKey = UIColor(red:0.00, green:0.19, blue:0.53, alpha:1.0)
    public var keyboardBackground = UIColor(red:0.00, green:0.19, blue:0.53, alpha:1.0)
    
    public var functionKeyTextColor = UIColor(red:1.0, green:1.0, blue:1.0, alpha:1.0)
    public var defaultKeyTextColor = UIColor(red:0.0, green:0.0, blue:0.0, alpha:1.0)
    
    public init () {
      
    }
  }
  
  public struct Qwerty {
    public var firstLine: String
    public var secondLine: String
    public var thirdLine : String
    
    public init(firstLine: String, secondLine: String, thirdLine: String){
      self.firstLine = firstLine
      self.secondLine = secondLine
      self.thirdLine = thirdLine
    }
    
  }
  
  public enum IKCipherTypes {
    case aes
    case custom
  }
  
  public struct IKCipher {
    public var key: Array<UInt8> = "aaaaaaaaaaaaaaaa".bytes
    public var iv: Array<UInt8> = "aaaaaaaaaaaaaaaa".bytes
    public var type: IKCipherTypes = .aes
    
    public init (){
    }
  }
  
  public var isUseSubKeys = true
  public var titleName = "CryptoKeyBoard"
  public var informationText = "This is Crypto Keyboard ViewController"
  public var cancelButtonName = "Close"
  
  public var numberQwerty = "1234567890"
  
  public var specialsQwerty = "!@#$%^&*()-=\\`_+|~[];',./{}:\"<>?"
  
  public var mainQwerty = Qwerty(firstLine: "qwertyuiop",
                                 secondLine: "asdfghjkl",
                                 thirdLine: "zxcvbnm")
  
  public var subQwerty = Qwerty(firstLine: "ㅂㅈㄷㄱㅅㅛㅕㅑㅐㅔ",
                                secondLine: "ㅁㄴㅇㄹㅎㅗㅓㅏㅣ",
                                thirdLine: "ㅋㅌㅊㅍㅠㅜㅡ")
  
  public var shiftMainQwerty = Qwerty(firstLine: "QWERTYUIOP",
                                      secondLine: "ASDFGHJKL",
                                      thirdLine: "ZXCVBNM")
  
  public var shiftSubQwerty = Qwerty(firstLine: "ㅃㅉㄸㄲㅆㅛㅕㅑㅒㅖ",
                                     secondLine: "ㅁㄴㅇㄹㅎㅗㅓㅏㅣ",
                                     thirdLine: "ㅋㅌㅊㅍㅠㅜㅡ")

  ...
  
  public init(){
    
  }
}

自定义示例

  • 德国 Crypt 键盘
configure.isUseSubKeys = false
    
configure.informationText = "This is Deutsch Crypto Keyboard"
configure.mainQwerty.firstLine = "qwertzuiopü"
configure.mainQwerty.secondLine = "asdfghjklöä"
configure.mainQwerty.thirdLine = "yxcvbnm"

configure.shiftMainQwerty.firstLine = "QWERTZUIOPÜ"
configure.shiftMainQwerty.secondLine = "ASDFGHJKLÖÄ"
configure.shiftMainQwerty.thirdLine = "YXCVBNM"

configure.color.defaultKey = .yellow
configure.color.touchedKey = .gray
configure.color.keyboardBackground = .black
configure.color.functionKeyTextColor = .white
configure.color.defaultKeyTextColor = .black
configure.color.functionKey = .red

  • 雷西恩 Crypt 键盘
configure.isUseSubKeys = false
configure.informationText = "This is Ressian Crypto Keyboard"
configure.mainQwerty.firstLine = "йцукенгшщзх"
configure.mainQwerty.secondLine = "фывапролджэ"
configure.mainQwerty.thirdLine = "ячсмитьбю"

configure.shiftMainQwerty.firstLine = "ЙЦУКЕНГШЩЗХ"
configure.shiftMainQwerty.secondLine = "ФЫВАПРОЛДЖЭ"
configure.shiftMainQwerty.thirdLine = "ЯЧСМИТЬБЮ"

configure.color.defaultKey = .white
configure.color.touchedKey = .gray
configure.color.keyboardBackground = .blue
configure.color.functionKeyTextColor = .black
configure.color.defaultKeyTextColor = .black
configure.color.functionKey = .red

使用自定义密码

如果你想使用自定义密码加密和解密,

let vc = IKCryptoKeyBoardViewController()
var configure = IKCryptoKeyBoardConfigure()
vc.configure.cipher.type = .custom // default is aes
vc.configure = configure

extension ViewController: IKCryptoKeyBoardViewControllerDelegate {
  func doEncrypt(plain: String) -> Array<UInt8> {
    // describe encrypt function
  }
  
  // for debug
  func doDecrypt(encrypted: Array<UInt8>) -> Array<UInt8> {
    // describe decrypt function
  }
}

作者

leibniz55, [email protected]

授权

IKCryptoKeyboard遵循MIT许可协议。详细信息请参阅LICENSE文件。