mirror of
https://github.com/anatolykopyl/know-own-checksum.git
synced 2026-03-26 04:45:27 +00:00
crc32 is a number
This commit is contained in:
@@ -21,7 +21,7 @@ local attempts = 0
|
|||||||
|
|
||||||
repeat
|
repeat
|
||||||
local random_crc32 = crc32.hash(attempts)
|
local random_crc32 = crc32.hash(attempts)
|
||||||
edit_file('i_know_my_crc32.lua', 13, "local crc32_expected = '" .. random_crc32 .. "'")
|
edit_file('i_know_my_crc32.lua', 13, "local crc32_expected = " .. random_crc32)
|
||||||
local match = require('i_know_my_crc32')
|
local match = require('i_know_my_crc32')
|
||||||
attempts = attempts + 1
|
attempts = attempts + 1
|
||||||
print(attempts)
|
print(attempts)
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ local crc32 = require 'crc32'
|
|||||||
local this_file = 'i_know_my_crc32.lua'
|
local this_file = 'i_know_my_crc32.lua'
|
||||||
|
|
||||||
function read_all(file)
|
function read_all(file)
|
||||||
local f = assert(io.open(file, "rb"))
|
local f = assert(io.open(file, "rb"))
|
||||||
local content = f:read("*all")
|
local content = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
return content
|
return content
|
||||||
end
|
end
|
||||||
|
|
||||||
local content = read_all(this_file)
|
local content = read_all(this_file)
|
||||||
local crc32_result = crc32.hash(content)
|
local crc32_result = crc32.hash(content)
|
||||||
local crc32_expected = ''
|
local crc32_expected = 000000000
|
||||||
|
|
||||||
print('My expected crc32 checksum is ' .. crc32_expected)
|
print('My expected crc32 checksum is ' .. crc32_expected)
|
||||||
print('My own crc32 checksum is ' .. crc32_result)
|
print('My own crc32 checksum is ' .. crc32_result)
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ local md5 = require 'md5'
|
|||||||
local this_file = 'i_know_my_md5.lua'
|
local this_file = 'i_know_my_md5.lua'
|
||||||
|
|
||||||
function read_all(file)
|
function read_all(file)
|
||||||
local f = assert(io.open(file, "rb"))
|
local f = assert(io.open(file, "rb"))
|
||||||
local content = f:read("*all")
|
local content = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
return content
|
return content
|
||||||
end
|
end
|
||||||
|
|
||||||
local content = read_all(this_file)
|
local content = read_all(this_file)
|
||||||
|
|||||||
Reference in New Issue
Block a user