From 5dd28d9ed497c75431411f5bac3bac5c5c8b38fb Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Fri, 11 Aug 2023 12:40:14 -0600 Subject: [PATCH] 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 --- utils/b64sha256/b64sha256.erl | 49 ----------------------------------- utils/b64sha256/b64sha384.erl | 49 ----------------------------------- 2 files changed, 98 deletions(-) delete mode 100755 utils/b64sha256/b64sha256.erl delete mode 100755 utils/b64sha256/b64sha384.erl diff --git a/utils/b64sha256/b64sha256.erl b/utils/b64sha256/b64sha256.erl deleted file mode 100755 index 8d5aaee..0000000 --- a/utils/b64sha256/b64sha256.erl +++ /dev/null @@ -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. diff --git a/utils/b64sha256/b64sha384.erl b/utils/b64sha256/b64sha384.erl deleted file mode 100755 index c0604a1..0000000 --- a/utils/b64sha256/b64sha384.erl +++ /dev/null @@ -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.