Skip to content

Instantly share code, notes, and snippets.

View divyeshmakwana96's full-sized avatar

Divyesh Makwana divyeshmakwana96

View GitHub Profile
@divyeshmakwana96
divyeshmakwana96 / StringHashAdditions.swift
Created September 22, 2020 00:13
MD5 and SHA1 with CommonCrypto in Swift 5.0
import Foundation
import CommonCrypto
extension String {
func sha1() -> [UInt8] {
let data = Data(string.utf8)
var digest = [UInt8](repeating: 0, count:Int(CC_SHA1_DIGEST_LENGTH))
data.withUnsafeBytes { _ = CC_SHA1($0.baseAddress, CC_LONG(data.count), &digest) }
return digest
@divyeshmakwana96
divyeshmakwana96 / UIStackViewExtensions.swift
Created July 19, 2019 19:07
UIStackView custom spacing extension
import UIKit
extension UIStackView {
struct Spacer {
var space: CGFloat = 0
init(_ space:CGFloat) {
self.space = space
}