Position: Home page » Blockchain » How to keep diary in blockchain

How to keep diary in blockchain

Publish: 2021-04-30 05:49:51
1. const SHA256 = require(crypto-js/SHA256);< br />class Block{
constructor(index,timestamp,data,previousHash='&# 39;)< br />{
this.index=index;< br />this.timestamp=timestamp;< br />this.data=data;< br />this.previousHash=previousHash;< br />$this.hash=this.calculateHash();< br />}

calculateHash(){
return SHA256(this,index+this.previousHash+this.timestamp+JSON.stringify(this.data)).tostring();< br />}
}
class blockchain{
constructor(){
this.chain=[this.createGenesisBlock()];<
}
/ / create a generated information block
creategenesis block() {
return new block (0, & quot; 01/01/2019",& quot; Genesis block", 0);
/ / the date is the user's data. In fact, it is the hash value obtained by adding several values together. Here, the information is encrypted and the picture is encrypted. Then the data is still stored in the database, but all the data are hash values. To get this data, you must know the hash value of the previous data block. Then, if the hacker needs to crack all the nodes, the hash value is decrypted, Then all the blocks from the first node to the last node can be decrypted to get the real data. So the security of data stored in the blockchain depends on whether the data is encrypted. If the plaintext is not encrypted, then it is not a blockchain
}
/ / get the last block
getlatesblock() {
return this.chain [this.chain. Length-1]
}
/ / create block
addblock (newblock) {
newblock. Previoushash = this. Getlatesblock(). Hash< br />newBlock.hash=newBlock.calculateHash();< br />this.chain.push(newBlock);< br />}
}
2. The information of each block in the blockchain is different, and the generation time and recorded data of each block are different. You can regard the blockchain as a bookkeeping book. Every once in a while, someone will write all the transaction information on the blockchain network to one page of the ledger, page by page, and record all the transactions on the blockchain network in turn according to the time
on the other hand, all nodes (computers in short) participating in the network will store one account book, which is updated in real time. Even if one node fails, the blockchain will not be affected.
3. The registered digital assets are stored in the blockchain. In essence, the blockchain is a decentralized distributed ledger database, which is a series of data blocks generated by the use of cryptography, and its characteristics are unchangeable and unforgeable. Similar to the digital asset registration business done by gold owners, it uses blockchain to store digital assets. In this way, every registration record of the platform can be traced, forged and tampered with. It is precisely because of this characteristic that when users have ownership disputes, such data can have credibility and can be provided to administrative departments as the basis for law enforcement.
4. How to store information on the blockchain: call the API provided by the blockchain platform

generally, the blockchain platform will provide corresponding interfaces, such as RPC, json-rpc, HTTP, etc. of course, the platforms are not the same, and the degree of friendliness is different

some companies specializing in API, such as blockcypher, can provide friendly calling interfaces, and it is not very convenient to write answers on the mobile phone, Search below

as for the storage content, add a point: in addition to the conventional cloud storage, file entities on the file hash record chain also have blockchain based storage schemes, such as IPFs, storej and so on
5.

In the traditional supply chain finance, financing difficulty, high financing cost and cumbersome financing process have always been one of the bottlenecks restricting small and medium-sized enterprises to become bigger and stronger. Banks rely on the ability of core enterprises to control goods and regulate sales. For the sake of risk control, banks are only willing to provide factoring services to upstream suppliers (limited to first tier suppliers) with direct accounts payable obligations of core enterprises, or provide prepayment or inventory financing to their downstream distributors (first tier suppliers). As a result, the demand of secondary and tertiary suppliers / distributors with huge financing demand can not be met, the business volume of supply chain finance is limited, and the small and medium-sized enterprises can not get timely financing, which will easily lead to proct quality problems and damage the whole supply chain system

to solve these problems, we can make use of the characteristics of decentralized, tamper proof and distributed ledger of blockchain technology to build a blockchain supply chain financial platform

The core enterprise issues a / R certificate to the distributor. After the distributor signs the receipt, it indicates that it has signed the purchase and sales contract and the core enterprise delivers the goods

Because of the shortage of funds, distributors need to borrow money from finance

3. After the financial institutions have approved, the amount of loans will be sent to the core enterprises

The distributor will repay the loan and interest after selling the goods

6. Encryption code. Every few minutes, a new block is generated, which stores different information and consists of different passwords (double keys).
7. Let's take personal information security as an example, because the disclosure of personal information will cause great harm to informants, making them suffer from conservative harassment. What's more terrible is personal information leakage, which is usually accompanied by tens of thousands of personal information being stolen, illegally sold, and even using the formal data trading institutions to steal data. With the rise of jinwowo blockchain technology, the encryption of blockchain technology can provide solutions for the protection of personal information. Blockchain technology can store personal information in a distributed way to avoid the security risks faced by a single server.
8. It seems that it is retained in Ethereum. Now the blockchain is becoming more and more popular. Changsha high tech Zone has also built a SMIC blockchain service platform, which is oriented to enterprise users. If the enterprise is on the chain, everyone has to trade in good faith. I hope the answer will help you. If you have any questions, you can continue to ask.
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750