Skip to content

SIO Command $C7 Hash Compute

Ripjetski edited this page Aug 23, 2023 · 4 revisions

This is a command for Device $70 - The FujiNet Device itself (see SIO-Commands-for-Device-ID-$70).

Hash Compute ($C7)

Description

Takes the data that was input by Hash Input, and hashes it with the selected hash algorithm. The result is put in the output buffer, so that Hash Output can be used to retrieve the output.

Supported hash types:

Type Value Notes
MD5 0 Currently not implemented
SHA1 1
SHA256 2
SHA512 3

Parameters

DCB Value
DDEVIC $70
DUNIT $01
DCOMND $C7
DSTATS $00
DBUF NULL
DTIMLO $03
DBYT 0
DAUX1 the hash type to compute
DAUX2 0

Examples

CC65

unsigned char hash_compute(void)                                                                                            
{                                                                                                                                    
  OS.dcb.ddevic   = BASE64_DEVICE;                                                                                                   
  OS.dcb.dunit    = 1;                                                                                                               
  OS.dcb.dcomnd   = 0xC7;                                                                                                            
  OS.dcb.dstats   = 0x00;                                                                                                            
  OS.dcb.dbuf     = NULL;                                                                                                            
  OS.dcb.dtimlo   = BASE64_TIMEOUT;                                                                                                  
  OS.dcb.dbyt     = 0;                                                                                                               
  OS.dcb.daux1    = 1;  // SHA1                                                                                                               
  siov();                                                                                                                            
                                                                                                                                     
  return OS.dcb.dstats; // Return SIO error or success.                                                                              
}                                    

Related Functions

Clone this wiki locally