Created
May 2, 2023 22:52
-
-
Save thomasjslone/91166afa571bf5d9ac0e9a0a6e1d1dfd to your computer and use it in GitHub Desktop.
file certs i cant wait to break
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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