Write a program or function (or set of programs/functions) to encrypt and decrypt data given the following specification:
Calculate an XOR hash of the input by XOR-ing every byte with each-other.
XOR every byte of the input by this hash.
Shift the result four bits left.
Pad the left side with the first four bits of the XOR hash.
Pad the right side with the last four bits of the XOR hash.
Calculate XOR hash:
0x47 ^ 0x30 ^ 0x6C ^ 0x66 = 0x7D
XOR every byte by hash:
Expected result (after shift and pad):
Your program/function can input/output of whatever type makes sense in your golfing language of choice (String, Byte Array, etc) as long as the input/output are the actual bytes. For example, you may not output a hexidecimal string.
Encryption and decryption can be separated into separate programs (score will be the their combined size) or a single one. Single methods can take an argument for whether it should encrypt or decrypt.
Input for encryption can be expected to be at least 1 byte in size.
Input for decryption can be expected to be at least 2 bytes.
Non-printable bytes do not need to be escaped in the output.