<commit_before>//
//  mdg-crypto.swift
//  MDG Nienburg
//
//  Created by <NAME> on 03.11.14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import UIKit
import SystemConfiguration

public enum IJReachabilityType {
    case wwan,
    wiFi,
    notConnected
}

extension String {
    
    func hmac(_ algorithm: HMACAlgorithm, key: String) -> String {
        let str = self.cString(using: String.Encoding.utf8)
        let strLen = Int(self.lengthOfBytes(using: String.Encoding.utf8))
        let digestLen = algorithm.digestLength()
        let result = UnsafeMutablePointer<CUnsignedChar>.allocate(capacity: digestLen)
        let objcKey = key as NSString
        let keyStr = objcKey.cString(using: String.Encoding.utf8.rawValue)
        let keyLen = Int(objcKey.lengthOfBytes(using: String.Encoding.utf8.rawValue))
        
        CCHmac(algorithm.toCCHmacAlgorithm(), keyStr, keyLen, str!, strLen, result)
        
        let hash = NSMutableString()
        for i in 0..<digestLen {
            hash.appendFormat("%02x", result[i])
        }
        
        result.deinitialize()
        
        return hash as String
    }
    func sha1() -> String {<commit_msg>Foundation import is enough<commit_after>//
//  mdg-crypto.swift
//  MDG Nienburg
//
//  Created by <NAME> on 03.11.14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Foundation
import SystemConfiguration

public enum IJReachabilityType {
    case wwan,
    wiFi,
    notConnected
}

extension String {
    
    func hmac(_ algorithm: HMACAlgorithm, key: String) -> String {
        let str = self.cString(using: String.Encoding.utf8)
        let strLen = Int(self.lengthOfBytes(using: String.Encoding.utf8))
        let digestLen = algorithm.digestLength()
        let result = UnsafeMutablePointer<CUnsignedChar>.allocate(capacity: digestLen)
        let objcKey = key as NSString
        let keyStr = objcKey.cString(using: String.Encoding.utf8.rawValue)
        let keyLen = Int(objcKey.lengthOfBytes(using: String.Encoding.utf8.rawValue))
        
        CCHmac(algorithm.toCCHmacAlgorithm(), keyStr, keyLen, str!, strLen, result)
        
        let hash = NSMutableString()
        for i in 0..<digestLen {
            hash.appendFormat("%02x", result[i])
        }
        
        result.deinitialize()
        
        return hash as String
    }
    func sha1() -> String {
{'fraction_non_alphanumeric': 0.10566037735849057, 'fraction_numerical': 0.01509433962264151, 'mean_word_length': 2.4680232558139537, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4792065', 'n_tokens_mistral': 761, 'n_tokens_neox': 718, 'n_words': 177}