Basic concept of blockchain

This commit is contained in:
vbodinaud
2020-02-27 16:29:33 +01:00
parent 29eeea28fd
commit 963a9b074a
5 changed files with 102 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
//
// 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: "")
}
}