Remove the scripts I wrote when I was being dumb

Recall that I had the problem of not being able to load NaCl into the context
of my background script.  I thought the problem was some nonsense with the way
"security" works in browser extensions.  There are some contexts where in order
to load a script, you must explicitly specify the SHA-256 or SHA-384 hash of
the script, in base64 notation.  I wrote these scripts for the purpose of
quickly reading a file and spitting out those values, so that I could easily
update the manifest as I was fooling around with the scripts.

It turned out that entire hypothesis was wrong: https://github.com/aeternity/Vanillae/commit/b680336ba464eafe63daafd95002f09e798c09d9

And therefore these scripts are now just junk
This commit is contained in:
2023-08-11 12:40:14 -06:00
parent 60f27b4952
commit 5dd28d9ed4
2 changed files with 0 additions and 98 deletions
-49
View File
@@ -1,49 +0,0 @@
#!/usr/bin/env escript
%% This is a script to print out the base64 representation of a sha256 hash of
%% input bytes. This exists because browser extensions are stupid. In order to
%% load a script into a page context it needs the sha256 hash encoded in base64
%% of the script. This script exists to just print that easily
-mode(compile).
%% either read from file or read stdin
main(["-e", FileName]) ->
{ok, Bytes} = file:read_file(FileName),
main_bytes(ext, Bytes);
main([FileName]) ->
{ok, Bytes} = file:read_file(FileName),
main_bytes(normal, Bytes);
main(["-e"]) ->
main_bytes(ext, read_stdin());
main([]) ->
main_bytes(normal, read_stdin()).
%% take sha256 of bytes and print in base64
%% print in manifest extension format
main_bytes(ext, Bytes) ->
Printing = main_bytes(Bytes),
io:format("'sha256-~ts'", [Printing]);
main_bytes(normal, Bytes) ->
Printing = main_bytes(Bytes),
io:format("~ts~n", [Printing]).
main_bytes(Bytes) ->
Sha256 = crypto:hash(sha256, Bytes),
base64:encode(Sha256).
read_stdin() ->
read_stdin(<<>>).
read_stdin(Acc) ->
ThisChar = io:get_chars(standard_io, "", 1),
case ThisChar of
eof ->
unicode:characters_to_binary(Acc);
{error, Reason} ->
error(Reason);
Char ->
read_stdin([Acc, Char])
end.
-49
View File
@@ -1,49 +0,0 @@
#!/usr/bin/env escript
%% This is a script to print out the base64 representation of a sha384 hash of
%% input bytes. This exists because browser extensions are stupid. In order to
%% load a script into a page context it needs the sha384 hash encoded in base64
%% of the script. This script exists to just print that easily
-mode(compile).
%% either read from file or read stdin
main(["-e", FileName]) ->
{ok, Bytes} = file:read_file(FileName),
main_bytes(ext, Bytes);
main([FileName]) ->
{ok, Bytes} = file:read_file(FileName),
main_bytes(normal, Bytes);
main(["-e"]) ->
main_bytes(ext, read_stdin());
main([]) ->
main_bytes(normal, read_stdin()).
%% take sha384 of bytes and print in base64
%% print in manifest extension format
main_bytes(ext, Bytes) ->
Printing = main_bytes(Bytes),
io:format("'sha384-~ts'", [Printing]);
main_bytes(normal, Bytes) ->
Printing = main_bytes(Bytes),
io:format("~ts~n", [Printing]).
main_bytes(Bytes) ->
Sha384 = crypto:hash(sha384, Bytes),
base64:encode(Sha384).
read_stdin() ->
read_stdin(<<>>).
read_stdin(Acc) ->
ThisChar = io:get_chars(standard_io, "", 1),
case ThisChar of
eof ->
unicode:characters_to_binary(Acc);
{error, Reason} ->
error(Reason);
Char ->
read_stdin([Acc, Char])
end.