Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Reading the Blockchain PHP code

<?php

class Blockchain {

  function read_all() {
    try {
      $jsondata = file_get_contents(dirname(dirname(__FILE__))."/chain.json");
      $arr_data = json_decode($jsondata, true);
      return $arr_data;
    }
    catch(Exception $e) {
      echo "Error: " . $e->getMessage();
      exit();
    }
  }

  function get_previous_hashid($chain){
    $lastEl = array_values(array_slice($chain, -1))[0];
    return $lastEl["hashid"];
  }

  function get_previous_index($chain){
    $lastEl = array_values(array_slice($chain, -1))[0];
    return $lastEl["index"];
  }

 function get_new_hashid($previous_hashid,$index,$timestamp,$content){
   $full_string = $previous_hashid.$index.$timestamp.$content;
   $hash  = hash('sha256',$full_string);
   return $hash;
 }

 function read_content($content) {
   $arr_content = json_decode($content);
   return $arr_content;
 }
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: run laravel envoy task 
Php :: command working in terminal but working from code php 
Php :: alert in php after header location 
Php :: PHP redirect parent page 
Php :: Validate checkboxes laravel 
Php :: array with key value pair php 
Php :: php code to display a div with background fade 
Php :: PHP catch eval output 
Php :: Adding Conditional Classes to Menu Items 
Php :: filter elementor 
Php :: razorpay refund laravel 
Php :: import data from csv laravel 
Php :: md5_file (PHP 4 = 4.2.0, PHP 5, PHP 7, PHP 8) md5_file — Calculates the md5 hash of a given file 
Php :: how to lookup value object php 
Php :: dorks 
Php :: change regards line laravel 
Php :: cant use migrate with sail laravel 
Php :: how to prevent iframe for your site by PHP 
Php :: @sectionMissing 
Php :: symfony postgresql 
Php :: 16 digit random password generator php code without function 
Php :: how to make custom sub menu admin wordpress dev 
Php :: phpexcel rangetoarray date format 
Php :: datatables compactible with bootstrap v4 
Php :: saber value ao escolher combobox php 
Php :: laravel gigapay get single employee 
Php :: pakistan standard time zone 
Php :: magento 2 create group programmatically 
Php :: php get last date of month 
Php :: Compare current time with another time in PHP 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =