Skip to content

Instantly share code, notes, and snippets.

View t089's full-sized avatar

Tobias t089

View GitHub Profile
@t089
t089 / Autolayout TableView header
Created December 14, 2018 13:21
UITableViewController+AutoLayoutHeaderView.swift
//
// ViewController.swift
// NaceApp
//
// Created by Tobias Haeberle on 14.12.18.
//
import UIKit
class ViewController: UITableViewController {
@t089
t089 / MD5.swift
Last active August 10, 2018 09:36
CommonCrypto
extension Array where Element == UInt8 {
var md5Hash: [UInt8] {
var hash = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH))
CC_MD5(self, UInt32(self.count), &hash)
return hash
}
var hexString : String {
return self.reduce(into: "", { $0 += String(format: "%02x", $1) })
}
@t089
t089 / Nonce.swift
Last active December 11, 2017 12:15
Creating a random NONCE in Swift
import Foundation
private let ALLOWED_BYTES: [UInt8] = [
// 0 1 2 3 4 5
0b00110000, 0b00110001, 0b00110010, 0b00110011, 0b00110100, 0b00110101,
// 6 7 8 9 A B
0b00110110, 0b00110111, 0b00111000, 0b00111001, 0b01000001, 0b01000010,
// C D E D G H
0b01000011, 0b01000100, 0b01000101, 0b01000110, 0b01000111, 0b01001000,
// I J K L M N