This file contains 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
#!/usr/bin/env julia | |
const ENTROPY_MAP_2D = open("entropy.csv") do f | |
readdlm(f, ',') | |
end | |
# Returns index 1:26 for a-z, 27 for space | |
function get_index_for(ch) | |
if 'a' <= ch <= 'z' | |
return int(ch - 96) |
This file contains 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
#!/usr/bin/env julia | |
# Adapted from https://github.com/pablocelayes/rsa-wiener-attack | |
using ContinuedFractions # Note: this needs my fork of ContinuedFractions.jl | |
# fast perfect square test (from project euler tools) | |
# returns -1 if n is not a perfect square | |
function perfect_square(n::Integer) | |
h = n & 0xF # last four bits |
This file contains 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
#!/usr/bin/env julia | |
using CRC | |
# crc computing function | |
const handler = crc(CRC_32) | |
# offsets of IDAT chunks (points to 'I' byte) | |
const offsets = [114,131197,262278,393361,524445,655526,786609,917691,1048775,1179858,1188429] | |
# correct crcs. No 0x0a in those so we can assume they're correct ;) | |
const crcs = [0xf55a745d, 0x06e15ebf, 0xa0bdc18a, 0xadefb326, 0x09c557f7, |
This file contains 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
#!/usr/bin/env perl | |
<>; | |
foreach(<>){ | |
s/(ij|[aeiou]+)p\1/\1/ig; | |
print; | |
} |
This file contains 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
#!/usr/bin/env perl | |
for (my $N=<>; $N; $N--){ | |
$_ = ""; | |
for (my $L=<>; $L; $L--) { | |
$_ .= <>; | |
} | |
for (my $L=<>; $L; $L--) { | |
my ($n, $r) = split(' ', <>); | |
s/($r( |$){$n}/\1/gm; |
NewerOlder