Skip to content

Instantly share code, notes, and snippets.

@thomasjslone
Created May 2, 2023 22:52
Show Gist options
  • Save thomasjslone/91166afa571bf5d9ac0e9a0a6e1d1dfd to your computer and use it in GitHub Desktop.
Save thomasjslone/91166afa571bf5d9ac0e9a0a6e1d1dfd to your computer and use it in GitHub Desktop.
file certs i cant wait to break
def generate_certificate(filepath)
file_size = File.size(filepath) # Get the size of the file
total = file_size # Iterate over every byte of the file and add its value to the size
File.open(filepath, "rb") do |file|
while byte = file.read(1)
total += byte.unpack('C').first
end
end
certificate = total.to_f / file_size # Divide the total by the size of the file to create the certificate
return certificate.to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment