Is there a way to open png files in typescript similar to the python method with open(path+im,"rb") as f:
? I have a folder with png files and I need to read and convert them to base 64. Can anyone assist me with the equivalent method in typescript?
This is the python code I currently have:
def image_integrity():
list_of_sha256 = []
path = "./nft_test/"
for im in os.listdir(path):
with open(path+im,"rb") as f:
f = base64.b64encode(f.read()) # read entire file as bytes
h = hashlib.new("sha256")
h.update(f)
result = h.digest()
result = base64.b64encode(result).decode("utf-8")
print(result)
list_of_sha256.append(result)
return list_of_sha256
and I am looking to rewrite it in typescript.