forked from Mirror/GodMode9
Scripting: allow 'shaget to store the SHA in a var
This commit is contained in:
parent
fad938b977
commit
5d9ed651cb
@ -154,8 +154,12 @@ sha $[RENPATH] $[TESTPATH].sha
|
||||
# sha S:/firm0.bin@100:100 078CC0CFD850A27093DDA2630C3603CA0C96969BD1F26DA48AC7B1BAE5DD5219
|
||||
|
||||
# 'shaget' COMMAND
|
||||
# Use this to calculate and store a files' SHA256
|
||||
# Use this to calculate (and store) a files' SHA256
|
||||
# If the second argument is a filename, the SHA256 will be stored there
|
||||
# shaget 0:/boot.firm 0:/boot.firm.sha
|
||||
# If it's a variable, it will be stored there temporarily instead
|
||||
shaget S:/nand_hdr.bin NANDHDRSHA
|
||||
sha S:/nand_hdr.bin $[NANDHDRSHA]
|
||||
# Partial SHA calculation is also possible (for @x:y handling see 'inject' below)
|
||||
# shaget 0:/boot.firm@100:100 0:/boot.firm.partial.sha
|
||||
|
||||
|
@ -673,6 +673,12 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) {
|
||||
u8 sha256_fil[0x20];
|
||||
if (!(ret = FileGetSha256(argv[0], sha256_fil, at_org, sz_org))) {
|
||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "sha arg0 fail");
|
||||
} else if (!strchr(argv[1], ':')) {
|
||||
char sha256_str[64+1];
|
||||
snprintf(sha256_str, 64+1, "%016llX%016llX%016llX%016llX", getbe64(sha256_fil + 0), getbe64(sha256_fil + 8),
|
||||
getbe64(sha256_fil + 16), getbe64(sha256_fil + 24));
|
||||
ret = set_var(argv[1], sha256_str);
|
||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "var fail");
|
||||
} else if (!(ret = FileSetData(argv[1], sha256_fil, 0x20, 0, true))) {
|
||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "sha write fail");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user