<commit_before>//
//  OTPToken.swift
//  OneTimePassword
//
//  Created by <NAME> on 6/10/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//


class OTPToken: NSObject {
    var name: String
    var issuer: String
    let type: TokenType
    let secret: NSData
    let algorithm: Algorithm
    let digits: Int
    var counter: UInt64 = 1
    var period: NSTimeInterval = 30

    init(type: TokenType, secret: NSData, name: String = "", issuer: String = "", algorithm: Algorithm = .SHA1, digits: Int = 6) {
        self.type = type
        self.secret = secret
        self.name = name
        self.issuer = issuer
        self.algorithm = algorithm
        self.digits = digits
    }

    func validate() -> Bool {
        var validType = (self.type == .Counter) || (self.type == .Timer)
        var validSecret = (self.secret.length > 0)
        var validAlgorithm = (self.algorithm == .SHA1 ||
                              self.algorithm == .SHA256 ||
                              self.algorithm == .SHA512)
        var validDigits = (self.digits >= 6) && (self.digits <= 8)
        var validCounter = (self.counter > 0)
        var validPeriod = (self.period > 0) && (self.period <= 300)

        return validType && validSecret && validAlgorithm && validDigits && validCounter && validPeriod
    }

    func description() -> String {
        return "<OTPToken type:\(type.toRaw()), name:\(name), issuer:\(issuer), algorithm:\(algorithm.toRaw()), digits:\(digits)>"
    }


    enum TokenType : String {
        case Counter = "hotp", Timer = "totp"
    }

    enum Algorithm : String {
        case SHA1 = "SHA1", SHA256 = "SHA256", SHA512 = "SHA512"
    }
}
<commit_msg>Remove unnecessary references to self<commit_after>//
//  OTPToken.swift
//  OneTimePassword
//
//  Created by <NAME> on 6/10/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//


class OTPToken: NSObject {
    var name: String
    var issuer: String
    let type: TokenType
    let secret: NSData
    let algorithm: Algorithm
    let digits: Int
    var counter: UInt64 = 1
    var period: NSTimeInterval = 30

    init(type: TokenType, secret: NSData, name: String = "", issuer: String = "", algorithm: Algorithm = .SHA1, digits: Int = 6) {
        self.type = type
        self.secret = secret
        self.name = name
        self.issuer = issuer
        self.algorithm = algorithm
        self.digits = digits
    }

    func validate() -> Bool {
        var validType = (type == .Counter) || (type == .Timer)
        var validSecret = (secret.length > 0)
        var validAlgorithm = (algorithm == .SHA1 ||
                              algorithm == .SHA256 ||
                              algorithm == .SHA512)
        var validDigits = (digits >= 6) && (digits <= 8)
        var validCounter = (counter > 0)
        var validPeriod = (period > 0) && (period <= 300)

        return validType && validSecret && validAlgorithm && validDigits && validCounter && validPeriod
    }

    func description() -> String {
        return "<OTPToken type:\(type.toRaw()), name:\(name), issuer:\(issuer), algorithm:\(algorithm.toRaw()), digits:\(digits)>"
    }


    enum TokenType : String {
        case Counter = "hotp", Timer = "totp"
    }

    enum Algorithm : String {
        case SHA1 = "SHA1", SHA256 = "SHA256", SHA512 = "SHA512"
    }
}

{'fraction_non_alphanumeric': 0.1332734351602276, 'fraction_numerical': 0.026954177897574125, 'mean_word_length': 2.1332082551594747, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '336734', 'n_tokens_mistral': 1077, 'n_tokens_neox': 974, 'n_words': 288}