Files
SwiftChain/Blockchain/Models/Block.swift
2020-02-27 16:29:33 +01:00

26 lines
530 B
Swift

//
// Block.swift
// Blockchain
//
// Created by Victor BODINAUD on 27/02/2020.
// Copyright © 2020 Victor BODINAUD. All rights reserved.
//
import Foundation
import CryptoKit
class Block {
var hash: String!
var data: String!
var previousHash: String!
var index: Int!
func generateHash() -> String {
if let hashData = data.data(using: .utf8) {
_ = SHA256.hash(data: hashData)
}
return NSUUID().uuidString.replacingOccurrences(of: "-", with: "")
}
}