Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

UNIX enhancements aren't.


devel / comp.lang.awk / Re: obfuscated AWK code challenge

Re: obfuscated AWK code challenge

<6ce272af-9f47-4811-a68b-cb84200d7629n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=988&group=comp.lang.awk#988

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:a37:bd05:: with SMTP id n5mr9094432qkf.293.1642248978564; Sat, 15 Jan 2022 04:16:18 -0800 (PST)
X-Received: by 2002:a25:a264:: with SMTP id b91mr17635137ybi.58.1642248978369; Sat, 15 Jan 2022 04:16:18 -0800 (PST)
Path: i2pn2.org!rocksolid2!news.neodome.net!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Sat, 15 Jan 2022 04:16:18 -0800 (PST)
In-Reply-To: <sqc2tq$jf6$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2603:7000:3c3d:41c0:0:0:0:3c3; posting-account=n74spgoAAAAZZyBGGjbj9G0N4Q659lEi
NNTP-Posting-Host: 2603:7000:3c3d:41c0:0:0:0:3c3
References: <db13b117-d555-4dab-885c-a3b706957cb3n@googlegroups.com> <sqc2tq$jf6$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6ce272af-9f47-4811-a68b-cb84200d7629n@googlegroups.com>
Subject: Re: obfuscated AWK code challenge
From: jason.cy.kwan@gmail.com (Kpop 2GM)
Injection-Date: Sat, 15 Jan 2022 12:16:18 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 270
 by: Kpop 2GM - Sat, 15 Jan 2022 12:16 UTC

the openssl part is only to do a real-time proving that whatever that was generated is indeed a 3312-bit prime number. The "bc" part is just to print that prime out in hex, that's all. if u want to u can ignore that part. i could add a bigint2hex function here but it would bloat it up.

when i posted this one, 3312-bit was the largest i found, with this output :

log-base-2 :: 3312.114313696145

# digits in decimal :: 998

0x 1151C1900FBB915A46082603C8F0F9A89505D3D11D440819AB64EC6F02A03DE9D9ADB5BE503EF7BF92835B5E480BA38B69DF05C51BC341797A7F830A27E5BD987D6F9FF7ADE7617228200D1457DD81512E421655F9AA1252496124EFA42A709113D454C7C605C13CAE151822938F9CF88F182868A5F6A8EA5A007181B734F37EE8287BEEBC65D79C45ED096CDA1212298ABDFC6740B545B2FBA76661A855AE963C14E370031656B010E8EBBEE709727B15B86DD0C2C85D30ECE5AE9485933B64A3F6D41913C83D6E0CD267B315A5BE712927B2940C52498CFE2CDC490FE243643D8D43BF359B2F220EED2CC77B1A00998A6968E13016DA892EC80B3E07A453CBAB356870BB4C87BE80C425B1B1D74C3BC4A0D000B10735C0C29B2885AD0D9929C7CB1C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C7111CF137D09F26D544CC35DBAF70FC67C02B7B5390BE713DA98BB8DB709D78DA1F0F9BFD19D7BA9DC48C0EE771761D5E72AA8E43E79211925708B0770CF93ECDF1C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C7

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 is prime

that's not a bit-string - that's a base-10 decimal number that happens to only have 1's and 0's. This code actually runs pretty fast - no recursion needed, no loops in the main body (other than setting up a lookup table at beginning)

it's Mcb cuz knowing the very speicific structure of only 1s, and 1 single zero, all i have to encode would be total length, and position of that zero

779 is the position, 998 is the length
779998
by ASCII ordinance numbers, 77,99,98 maps to M, c, and b, which is even more efficient encoding that trying to encode that number in hex, which is BE6DE. Print that hex out as bytes x0B xE6 xDE and it's still 3-bytes needed, but won't be particularly human-readable.

that's before. since the original posting, using the same technique, i could now encode a 13,789-bit prime using just 4 bytes (see below). What's the point ? i'm curious if any algorithm, anywhere, can achieve a better compression ratio than that. RLE is still much larger, as is LZW or LZMA.

u can say mine is a bit cheating, since it's not a generic algorithm - i see it as : decompression algorithms are just a form of lossless reconstruction, so why limit the possibilities, as long as the output is what's intended ? there are algorithms optimized for lossless compression of audio, like FLAC, so perhaps there should also be compression algorithms optimized for the key exchanges in cryptography .

Make the overhead low enough, and we could even move to a paradigm where every other message, or even every message, is a different one-time key.

function __________(__,_,___) {
(___="bc <<< \"obase="(_*=_^=\
_+=++_)"; "(__)" ;\"")|getline _;
close(___); return _ };

function _________(_,__,___,____,
_____,______,_______,________) {
_____="%c";
for(_-=(___-=(_=(_*=_*=_*=\
________=_+=++_)))^!_;\
-""<=_;_--) {__[\
sprintf(_____,___-+-_)]=\
(((______=sprintf(substr(_____,\
_^!___,!-"")(+"")(_______)"d",_)\
)!~/.../)?______\
: substr(______,(!-"")+(!-"")))
};for(_ in __) {
__[_] }
____=+(_______="")
_______=_=-(\
_^=_^=_+=_^=_="")
for(_=_____=length(____=sprintf(\
"%c%c%c%c",\
_______+(4-6)^6-4*6+4^!6,\
_______+46+6,\
_______+(4+6)^(-4+6),_______+46));_;_--) {
___=__[substr(____,_,!!_)]___;
}
if ((______=___%(_____=\
((!-"")(-""))^(_____*=\
(_^=_=-"")^-!-"")))<(_______=\
int(___/_____))) {___=______;
______=_______;_______=___}
___="%*.f";________=sprintf(\
(___"_")___,--_______,!_,\
--______+-+_______,!___)
gsub(/[^_]/,_^!_,________)
sub(/[_]/,+"",________)
sub(/..$/,"",_____)
_____=(_+=_^=_="")^_*_+_;
printf(" log-base-"(_)" :: %."(\
_^_^_)"g\n\n %c digits in "\
"decimal :: %d\n\n 0x %s\n\n",\
(log((".")(substr(________,_/_,\
_____*_*_____)))+log(_____)*(___=\
length(________)))/log(_),_____/-_+\
_^_*_____,___, __________(________))
system("openssl prime "\
" "(________)); return ________ };

log-base-2 :: 13789.47552497089

# digits in decimal :: 4152

0x 2C7E5AA2F0BE2B80FF9069A51FD1F58B439FCA60DEDD9D7F4F12FDCCAECEA620CC211B4A3DDB9E1CC7C6A478ACDD0DA895D8FA594B723A6D8F8D0A9998B2640A2089A54D82480D1218C764285FD9F96D8222623E64E7FD9C5B33359DC5B3C87591CE9BC6CE493E9CD0FA633BEC77432074E6E4FBB04D0BD33C9E4BE92076D7DFC75D6A78BCCE4D0A80949167BA292C7756CD0A7311118394E74D99728A2175149F57E0B3B081530AC1DFB6D05EFB02E82A83EBE03A4B73350EC780788438340462CB782ED9A5F3208DB16392CED5E976BCF1E385D88A494214F20186945A74151DFB107DFC33C3371E314C26906C5D5696F47E75F186D61454EE594A0254DAA1877CAB24B23547D3FEB04E89DAEAD6577EF7251F893493FBD28E3D1045579BD9C9F8133001600F2D9A7B290350CB9A736D8D4F07C7183A6A6A8676204B692F7341FC8EE68D3DC20E00B015FBB946C7999A42DCFC26B6D78ECDCAD06457BE0BD51604C823DB5948AFB7F038ED981DBCDCCBF401DEC2C0F803A69DE914BE1B99FBA80EA6CB41EB2F1D9DCE7DC1D14753F354B775B5E780C7B4114F241237691BF8549EC6D54F4A718CB81C35DE1E6DA861C56B57BA87998218EA10497378C60E2467CC5E20E54E583EF1396EE0BBEA29CD70B57515D8FCC44D681098EE61FE24D4D9CFAC54E2A63ACA9DBBB470291AB988346D7A015CE7C0DC0464FB5272512149266B1BF1E292EB788B74EC716DA132FDD0FA4D1D66823E12748ECC06536A0956BAF2C6C1656A5A6C1E612E30263DECBD1FBBD34383DD34E6A7FF6FA0C19A264CF24E8374F5E55CF9B755BB00969F940D08384E1FB6A81C838E763953A8F8F0734570261AB051903A123BBA8FE4AF37FB36C4E61497FD5ECB84C1A170777591AB46513006859C777F91FDAA1464B7158258E83F27081ABA1F5B66F8377DA9EB96D4124C322FF5C0721CB097D317380EDC375F526B62B5D736F59FCC749B1C145584CE60ED15FE804FC4D533CCFA6DB77B0352B177A2E587D6D35932197969B20DB2327BE2DEF73EC46BDC17358B10ACFB4B01D460930BC27B3EE11EE69692E4554C396231E8103B479335A68155949A9D2021C2D30AD16AB295339FA5D9BA7BBAA713F0AC26D8A5292AFC7F94583F3F0B193CCF6AC450178218EBA7D2396531B1F48A7ADF6915B0BEE0A2AF6C875A13145AABECADC63FCCCDEB097496C1115387690B2DDD4C51B6E22F8E060841AF02A4AFEB62A25B67C872E232F6C70EAD3222E57BB12823C34225A12503549FB9F3E5D8967AD738B4D28FF72EC8FBAD18CF4AB82BD50F35B7A9A9D41CB27506363404D6092670C018F41D951A7F342CF5363459DAEC4E38B4797FACE0DF7356F67CE9694469AE27C68DC13C12EC6ACDB8F003C775B19650B9AACAB3C97CE2F8EC78EA7F05F7B3211EEA6A8006316AE93EF4811ED6688F8BA34A7119B16438FD14EC1A21F22868738EA7D8F95E895438F1E7FA199E904A2869C39AEA681B10E7E00555539730E9CD1E4D842C31B1156ECCEE49B3E83F1542D6CC3CBD4E487D48832E7F4C93261F2792192146A429763E9B641A548492A5E0E76CAE75DB5D1B0F919FC79E15FA793027F1F9FC9B8DA1C2FEB40B56AB442135606BE914B620541BB552F2D0A558E1133581E3749C4EBE585D68F31E70AE62965579F671EAD5F5006D25069BE5C46C4B5C5A8B2165E31C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C71C7

111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 is prime

On Monday, December 27, 2021 at 5:01:32 AM UTC-5, Janis Papanagnou wrote:
> Subject: Re: obfuscated AWK code challenge
>
> It's arguable whether it's appropriate to call code an "AWK code
> challenge" that obviously relies on external commands like 'od',
> 'openssl', and various shell commands _within_ the awk code.
>
> Janis
> On 27.12.2021 03:53, RARE Kpop Manifesto wrote:
> > without actually running this code, can you figure out which prime number has been encoded within the input of ASCII letters
> >
> > [ Mcb ]
> >
> > plus the trick that allowed me to achieve such a compression ratio.
> >
> > * The code works equally well in gawk, mawk-1, mawk2, and nawk.
> > It is ENTIRELY self-encapsulated.
> >
> > Enjoy !
> >
> > = === === === === === === === === === === === === ==
> >
> > echo; cmd=' echo Mcb | mawk2 '\''function _________(__,_,___) { (___="bc <<< \"obase="(_*=_^=_+=++_)"; "(__)" ;\"")|getline _; close(___); return _ } BEGIN {_____="%c";for(_-=(___-=(_=(_*=_*=_*=_+=++_)))^!_;-""<=_;_--) {__[sprintf(_____,___-+-_)]=_}; for(_ in __) { __[_] } } {____=+""; for(_=_____=length($(____));_;_--) { ___=__[substr($(____),_,!!_)]___ }; ______=___%(_____=((!-"")(-""))^(_____*=(_^=_=-"")^-!-""));_______=int(___/_____);___="%*.f"; ________=sprintf((___"_")___,--_______,!_,--______+-+_______,!___); gsub(/[^_]/,_^!_,________); sub(/[_]/,+"",________); sub(/..$/,"",_____);_____+=_="";_+=_^=_; printf(" log-base-"(_)" :: %."(_^_^_)"g%c%c %c digits in decimal :: %d%c%c 0x %s%c%c",log(_)^(_/-_)*(log((".")(________))+log(_____)*(___=length(________))), _____, _____,_^_*_____-_^-!!_*_____,___,_____,_____, _________(________), _____,_____); system("openssl prime -checks "(_+=_*=(_^=_)*_)" "(________)) }'\'' '; gprintf '\n%s\n\n' "${cmd}" ; echo; eval "${cmd}"
> >

SubjectRepliesAuthor
o obfuscated AWK code challenge

By: RARE Kpop Manifesto on Mon, 27 Dec 2021

25RARE Kpop Manifesto
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor