Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
sha256.c File Reference

Implements OP_OPENSSL_SHA256 to compute a SHA-256 hash in hex. More...

Go to the source code of this file.

Functions

 free_value (vdata)
 if (!s)
 free (s)
 free (hex)
 push_value (vm, out)

Variables

case OP_OPENSSL_SHA256
char * s = value_to_string_alloc(&vdata)
char * hex = fun_openssl_sha256_hex((const unsigned char *)s, strlen(s))
Value out = make_string(hex)
 break

Detailed Description

Implements OP_OPENSSL_SHA256 to compute a SHA-256 hash in hex.

Behavior:

  • Pops one value from the VM stack and converts it to bytes by first producing its string form with value_to_string_alloc().
  • Computes the SHA-256 digest via fun_openssl_sha256_hex() and pushes the lowercase hexadecimal string.
  • On allocation or hashing failure, pushes an empty string ("").

Notes:

  • Non-string inputs are allowed; values are stringified first.
  • Snippet is included by vm.c and executed for OP_OPENSSL_SHA256.

Errors:

  • No hard VM error is raised; failures push an empty string.

Definition in file sha256.c.

Function Documentation

◆ free() [1/2]

free(hex)

◆ free() [2/2]

free(s)

◆ free_value()

free_value(vdata)

◆ if()

if(!s)

Definition at line 33 of file sha256.c.

Here is the call graph for this function:

◆ push_value()

push_value(vm,
out )
Here is the caller graph for this function:

Variable Documentation

◆ break

break

Definition at line 46 of file sha256.c.

◆ hex

char* hex = fun_openssl_sha256_hex((const unsigned char *)s, strlen(s))

Definition at line 37 of file sha256.c.

◆ OP_OPENSSL_SHA256

case OP_OPENSSL_SHA256

Definition at line 29 of file sha256.c.

◆ out

Definition at line 43 of file sha256.c.

◆ s

char* s = value_to_string_alloc(&vdata)

Definition at line 31 of file sha256.c.