So you could probably reduce that code down to:
import Array "mo:base/Array";
import Hex "../vendor/motoko-hex/src/Hex";
import Prim "mo:prim";
import SHA256 "../vendor/motoko-sha/src/SHA256";
actor {
public func sha256TextToHexText(text : Text) : async Text {
let data = Array.init<Word8>(text.size(), 0);
var i = 0;
for (char in text.chars()) {
data[i] := Prim.natToWord8(Prim.word32ToNat(Prim.charToWord32(char)));
i += 1;
};
let hash = SHA256.sha256(Array.freeze(data));
return Hex.encode(hash);
};
};