About Monkey 2 › Forums › Monkey 2 Development › MD5 hash
This topic contains 17 replies, has 6 voices, and was last updated by
scurty 1 year, 3 months ago.
-
AuthorPosts
-
December 15, 2017 at 10:42 am #12304
I’ve been looking through the documents, but find no mention of MD5 hash.
Is there a simple way to get the MD5 hash of a string?December 15, 2017 at 1:30 pm #12308Doubt anything built-in, but these BlitzMax Code Archives versions should port trivially:
http://wasted.nz/codearcs.php?code=1449
http://wasted.nz/codearcs.php?code=1378December 16, 2017 at 1:02 am #12317If anyone translates it please post.
Would help a great deal.Not sure what this means. :+
h0 :+ a ; h1 :+ b
h2 :+ c ; h3 :+ d
December 16, 2017 at 1:44 am #12318I won’t be home for a while, so I can’t do it right now.
But :+ means +=Here’s some Monkey X source code: http://wasted.nz/posts.php?topic=203483#6
December 16, 2017 at 2:14 am #12319RotateLeft() uses Lsl() and Lsr()
Is this just Bit shifting? Not found in Monkey2Think this is the last thing that needs translating.
December 16, 2017 at 2:26 am #12320Shr Shl?
Monkey 2 can probably do what some of those functions do.
So it’ll be a sort of a waste doing a raw translate, but I guess it’s better than nothing!December 16, 2017 at 2:32 am #12321Oi, bugs everywhere. o.O
I’m not build for this. Lol!
Not luck yet. Consider me out.Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172Namespace stdFunction MD5:String(sMessage:String)'Pads the String as per the MD5 standardLocal sMessageLen:Int = sMessage.LengthLocal nblk:Int = ((sMessageLen + 8) Shr 6) + 1 'number of 16-word blocksLocal MD5_x:Int[] = New Int[](nblk * 16)MD5_x.Resize(nblk * 16)'Zero pad the StringLocal i:Int , k:IntFor i = 0 To (nblk * 16) - 1MD5_x[i] = 0Next'Convert To array of "words"For i = 0 To sMessageLen - 1MD5_x[(i Shr 2)] = MD5_x[(i Shr 2)] | ( sMessage[i] Shl ((i Mod 4) * 8))NextMD5_x[(i Shr 2)] = MD5_x[(i Shr 2)] | (128 Shl (((i) Mod 4) * 8))MD5_x[nblk * 16 - 2] = sMessageLen * 8'Set initial valuesLocal MD5_a:Int = 1732584193 '&H67452301Local MD5_b:Int = -271733879 '&HEFCDAB89Local MD5_c:Int = -1732584194 '&H98BADCFELocal MD5_d:Int = 271733878 '&H10325476'Loop through the wordsFor k = 0 To (nblk * 16 - 1) Step 16Local MD5_AA:Int = MD5_aLocal MD5_BB:Int = MD5_bLocal MD5_CC:Int = MD5_cLocal MD5_DD:Int = MD5_d'Round 1MD5_a = MD5_FF(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 0], 7, -680876936) '&HD76AA478MD5_d = MD5_FF(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 1], 12, -389564586) '&HE8C7B756MD5_c = MD5_FF(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 2], 17, 606105819 )'&H242070DBMD5_b = MD5_FF(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 3], 22, -1044525330) '&HC1BDCEEEMD5_a = MD5_FF(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 4], 7, -176418897) '&HF57C0FAFMD5_d = MD5_FF(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 5], 12, 1200080426 )'&H4787C62AMD5_c = MD5_FF(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 6], 17, -1473231341) '&HA8304613MD5_b = MD5_FF(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 7], 22, -45705983) '&HFD469501MD5_a = MD5_FF(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 8], 7, 1770035416) '&H698098D8MD5_d = MD5_FF(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 9], 12, -1958414417 )'&H8B44F7AFMD5_c = MD5_FF(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 10], 17, -42063 )'&HFFFF5BB1MD5_b = MD5_FF(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 11], 22, -1990404162) '&H895CD7BEMD5_a = MD5_FF(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 12], 7, 1804603682) '&H6B901122MD5_d = MD5_FF(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 13], 12, -40341101) '&HFD987193MD5_c = MD5_FF(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 14], 17, -1502002290) '&HA679438EMD5_b = MD5_FF(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 15], 22, 1236535329) '&H49B40821'Round 2MD5_a = MD5_GG(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 1], 5, -165796510) '&HF61E2562MD5_d = MD5_GG(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 6], 9, -1069501632) '&HC040B340MD5_c = MD5_GG(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 11], 14, 643717713) '&H265E5A51MD5_b = MD5_GG(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 0], 20, -373897302) '&HE9B6C7AAMD5_a = MD5_GG(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 5], 5, -701558691) '&HD62F105DMD5_d = MD5_GG(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 10], 9, 38016083) '&H2441453MD5_c = MD5_GG(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 15], 14, -660478335) '&HD8A1E681MD5_b = MD5_GG(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 4], 20, -405537848) '&HE7D3FBC8MD5_a = MD5_GG(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 9], 5, 568446438) '&H21E1CDE6MD5_d = MD5_GG(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 14], 9, -1019803690) '&HC33707D6MD5_c = MD5_GG(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 3], 14, -187363961) '&HF4D50D87MD5_b = MD5_GG(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 8], 20, 1163531501) '&H455A14EDMD5_a = MD5_GG(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 13], 5, -1444681467) '&HA9E3E905MD5_d = MD5_GG(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 2], 9, -51403784) '&HFCEFA3F8MD5_c = MD5_GG(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 7], 14, 1735328473) '&H676F02D9MD5_b = MD5_GG(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 12], 20, -1926607734) '&H8D2A4C8A'Round 3MD5_a = MD5_HH(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 5], 4, -378558) '&HFFFA3942MD5_d = MD5_HH(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 8], 11, -2022574463) '&H8771F681MD5_c = MD5_HH(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 11], 16, 1839030562) '&H6D9D6122MD5_b = MD5_HH(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 14], 23, -35309556) '&HFDE5380CMD5_a = MD5_HH(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 1], 4, -1530992060) '&HA4BEEA44MD5_d = MD5_HH(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 4], 11, 1272893353) '&H4BDECFA9MD5_c = MD5_HH(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 7], 16, -155497632) '&HF6BB4B60MD5_b = MD5_HH(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 10], 23, -1094730640) '&HBEBFBC70MD5_a = MD5_HH(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 13], 4, 681279174) '&H289B7EC6MD5_d = MD5_HH(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 0], 11, -358537222) '&HEAA127FAMD5_c = MD5_HH(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 3], 16, -722521979) '&HD4EF3085MD5_b = MD5_HH(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 6], 23, 76029189) '&H4881D05MD5_a = MD5_HH(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 9], 4, -640364487) '&HD9D4D039MD5_d = MD5_HH(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 12], 11, -421815835) '&HE6DB99E5MD5_c = MD5_HH(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 15], 16, 530742520) '&H1FA27CF8MD5_b = MD5_HH(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 2], 23, -995338651) '&HC4AC5665'Round 4MD5_a = MD5_II(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 0], 6, -198630844) '&HF4292244MD5_d = MD5_II(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 7], 10, 1126891415) '&H432AFF97MD5_c = MD5_II(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 14], 15, -1416354905) '&HAB9423A7MD5_b = MD5_II(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 5], 21, -57434055) '&HFC93A039MD5_a = MD5_II(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 12], 6, 1700485571) '&H655B59C3MD5_d = MD5_II(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 3], 10, -1894986606) '&H8F0CCC92MD5_c = MD5_II(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 10], 15, -1051523) '&HFFEFF47DMD5_b = MD5_II(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 1], 21, -2054922799) '&H85845DD1MD5_a = MD5_II(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 8], 6, 1873313359) '&H6FA87E4FMD5_d = MD5_II(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 15], 10, -30611744) '&HFE2CE6E0MD5_c = MD5_II(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 6], 15, -1560198380 )'&HA3014314MD5_b = MD5_II(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 13], 21, 1309151649) '&H4E0811A1MD5_a = MD5_II(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 4], 6, -145523070) '&HF7537E82MD5_d = MD5_II(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 11], 10, -1120210379) '&HBD3AF235MD5_c = MD5_II(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 2], 15, 718787259) '&H2AD7D2BBMD5_b = MD5_II(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 9], 21, -343485551) '&HEB86D391MD5_a = MD5_a + MD5_AAMD5_b = MD5_b + MD5_BBMD5_c = MD5_c + MD5_CCMD5_d = MD5_d + MD5_DDNextReturn WordToHex(MD5_a) + WordToHex(MD5_b) + WordToHex(MD5_c) + WordToHex(MD5_d)End FunctionFunction MD5_F:Int(x:Int, y:Int, z:Int)Return ((x & y) | (~(x) & z))End FunctionFunction MD5_G:Int(x:Int, y:Int, z:Int)Return ((x & z) | (y & (~(z))))End FunctionFunction MD5_H:Int(x:Int, y:Int, z:Int)Return (x ~ y ~ z)End FunctionFunction MD5_I:Int(x:Int, y:Int, z:Int)Return (y ~ (x | (~z)))End FunctionFunction MD5_FF:Int(a:Int, b:Int, c:Int, d:Int, x:Int, s:Int, ac:Int)a = (a + ((MD5_F(b, c, d)+ x)+ ac))a = RotateLeft(a, s)Return a + bEnd FunctionFunction MD5_GG:Int(a:Int, b:Int, c:Int, d:Int, x:Int, s:Int, ac:Int)a = (a + ((MD5_G(b, c, d) + x) + ac))a = RotateLeft(a, s)Return a + bEnd FunctionFunction MD5_HH:Int(a:Int, b:Int, c:Int, d:Int, x:Int, s:Int, ac:Int)a = (a + ((MD5_H(b, c, d) + x) + ac))a = RotateLeft(a, s)Return a + bEnd FunctionFunction MD5_II:Int(a:Int, b:Int, c:Int, d:Int, x:Int, s:Int, ac:Int)a = (a + ((MD5_I(b, c, d) + x) + ac))a = RotateLeft(a, s)Return a + bEnd FunctionFunction RotateLeft:Int(lValue:Int, iShiftBits:Int)Return (lValue Shl iShiftBits) | ( lValue Shr (32 - iShiftBits) )'Return Lsl( lValue,iShiftBits) | Lsr( lValue, (32 - iShiftBits))End FunctionFunction DecToHex:String(v:Int)Const hex:String = "0123456789abcdef"Local n:StringFor Local i:Int = 0 Until 8n += String.FromChar(hex[(v Shr (28-(i*4))) & $F])NextReturn nEnd FunctionFunction WordToHex:String(lValue:Int)Local returnString:StringreturnString = DecToHex( lValue )Return returnString.Slice(6, 8) + returnString.Slice(4, 6) + returnString.Slice(2, 4)+ returnString.Slice(0, 2)'Return returnString[6..8] + returnString[4..6] + returnString[2..4] + returnString[0..2]End FunctionDecember 19, 2017 at 10:38 pm #12377Anyone else wanting to give this a go? heh
December 20, 2017 at 2:37 am #12378Will have a hack tomorrow/soon.
December 20, 2017 at 3:44 am #12379I did managed to convert that example:
[/crayon]Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165[crayon-5cb9b30237b29765575729 inline="true" ]Import "<std>"Using std..Global MD5_x:Int[]'MD5 for BlitzMax'Derived from Craig Kiesau's BlitzBasic MD5 function'Derived from the RSA Data Security, Inc. MD5 Message-Digest AlgorithmFunction MD5:String(sMessage:String)Local i:Int'Pads the String as per the MD5 standardLocal nblk:Int = ((sMessage.Length + 8) Shr 6) + 1 'number of 16-word blocksLocal MD5_x := New Int[(nblk * 16)]'Zero pad the StringFor i = 0 To nblk * 16 - 1MD5_x[i] = 0Next'Convert To array of "words"For i = 0 To (sMessage.Length - 1)MD5_x[(i Shr 2)] = MD5_x[(i Shr 2)] | (sMessage[i + 1] Shl ((i Mod 4) * 8))NextMD5_x[(i Shr 2)] = MD5_x[(i Shr 2)] | (128 Shl (((i) Mod 4) * 8))MD5_x[nblk * 16 - 2] = (sMessage.Length) * 8'Set initial valuesLocal MD5_a:Int = 1732584193 '&H67452301Local MD5_b:Int = -271733879 '&HEFCDAB89Local MD5_c:Int = -1732584194 '&H98BADCFELocal MD5_d:Int = 271733878 '&H10325476'Loop through the wordsFor Local k:Int = 0 To (nblk * 16 - 1) Step 16Local MD5_AA:Int = MD5_aLocal MD5_BB:Int = MD5_bLocal MD5_CC:Int = MD5_cLocal MD5_DD:Int = MD5_d'Round 1MD5_a = MD5_FF(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 0], 7, -680876936) '&HD76AA478MD5_d = MD5_FF(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 1], 12, -389564586) '&HE8C7B756MD5_c = MD5_FF(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 2], 17, 606105819 )'&H242070DBMD5_b = MD5_FF(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 3], 22, -1044525330) '&HC1BDCEEEMD5_a = MD5_FF(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 4], 7, -176418897) '&HF57C0FAFMD5_d = MD5_FF(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 5], 12, 1200080426 )'&H4787C62AMD5_c = MD5_FF(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 6], 17, -1473231341) '&HA8304613MD5_b = MD5_FF(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 7], 22, -45705983) '&HFD469501MD5_a = MD5_FF(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 8], 7, 1770035416) '&H698098D8MD5_d = MD5_FF(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 9], 12, -1958414417 )'&H8B44F7AFMD5_c = MD5_FF(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 10], 17, -42063 )'&HFFFF5BB1MD5_b = MD5_FF(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 11], 22, -1990404162) '&H895CD7BEMD5_a = MD5_FF(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 12], 7, 1804603682) '&H6B901122MD5_d = MD5_FF(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 13], 12, -40341101) '&HFD987193MD5_c = MD5_FF(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 14], 17, -1502002290) '&HA679438EMD5_b = MD5_FF(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 15], 22, 1236535329) '&H49B40821'Round 2MD5_a = MD5_GG(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 1], 5, -165796510) '&HF61E2562MD5_d = MD5_GG(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 6], 9, -1069501632) '&HC040B340MD5_c = MD5_GG(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 11], 14, 643717713) '&H265E5A51MD5_b = MD5_GG(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 0], 20, -373897302) '&HE9B6C7AAMD5_a = MD5_GG(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 5], 5, -701558691) '&HD62F105DMD5_d = MD5_GG(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 10], 9, 38016083) '&H2441453MD5_c = MD5_GG(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 15], 14, -660478335) '&HD8A1E681MD5_b = MD5_GG(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 4], 20, -405537848) '&HE7D3FBC8MD5_a = MD5_GG(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 9], 5, 568446438) '&H21E1CDE6MD5_d = MD5_GG(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 14], 9, -1019803690) '&HC33707D6MD5_c = MD5_GG(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 3], 14, -187363961) '&HF4D50D87MD5_b = MD5_GG(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 8], 20, 1163531501) '&H455A14EDMD5_a = MD5_GG(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 13], 5, -1444681467) '&HA9E3E905MD5_d = MD5_GG(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 2], 9, -51403784) '&HFCEFA3F8MD5_c = MD5_GG(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 7], 14, 1735328473) '&H676F02D9MD5_b = MD5_GG(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 12], 20, -1926607734) '&H8D2A4C8A'Round 3MD5_a = MD5_HH(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 5], 4, -378558) '&HFFFA3942MD5_d = MD5_HH(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 8], 11, -2022574463) '&H8771F681MD5_c = MD5_HH(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 11], 16, 1839030562) '&H6D9D6122MD5_b = MD5_HH(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 14], 23, -35309556) '&HFDE5380CMD5_a = MD5_HH(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 1], 4, -1530992060) '&HA4BEEA44MD5_d = MD5_HH(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 4], 11, 1272893353) '&H4BDECFA9MD5_c = MD5_HH(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 7], 16, -155497632) '&HF6BB4B60MD5_b = MD5_HH(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 10], 23, -1094730640) '&HBEBFBC70MD5_a = MD5_HH(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 13], 4, 681279174) '&H289B7EC6MD5_d = MD5_HH(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 0], 11, -358537222) '&HEAA127FAMD5_c = MD5_HH(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 3], 16, -722521979) '&HD4EF3085MD5_b = MD5_HH(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 6], 23, 76029189) '&H4881D05MD5_a = MD5_HH(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 9], 4, -640364487) '&HD9D4D039MD5_d = MD5_HH(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 12], 11, -421815835) '&HE6DB99E5MD5_c = MD5_HH(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 15], 16, 530742520) '&H1FA27CF8MD5_b = MD5_HH(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 2], 23, -995338651) '&HC4AC5665'Round 4MD5_a = MD5_II(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 0], 6, -198630844) '&HF4292244MD5_d = MD5_II(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 7], 10, 1126891415) '&H432AFF97MD5_c = MD5_II(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 14], 15, -1416354905) '&HAB9423A7MD5_b = MD5_II(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 5], 21, -57434055) '&HFC93A039MD5_a = MD5_II(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 12], 6, 1700485571) '&H655B59C3MD5_d = MD5_II(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 3], 10, -1894986606) '&H8F0CCC92MD5_c = MD5_II(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 10], 15, -1051523) '&HFFEFF47DMD5_b = MD5_II(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 1], 21, -2054922799) '&H85845DD1MD5_a = MD5_II(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 8], 6, 1873313359) '&H6FA87E4FMD5_d = MD5_II(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 15], 10, -30611744) '&HFE2CE6E0MD5_c = MD5_II(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 6], 15, -1560198380 )'&HA3014314MD5_b = MD5_II(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 13], 21, 1309151649) '&H4E0811A1MD5_a = MD5_II(MD5_a, MD5_b, MD5_c, MD5_d, MD5_x[k + 4], 6, -145523070) '&HF7537E82MD5_d = MD5_II(MD5_d, MD5_a, MD5_b, MD5_c, MD5_x[k + 11], 10, -1120210379) '&HBD3AF235MD5_c = MD5_II(MD5_c, MD5_d, MD5_a, MD5_b, MD5_x[k + 2], 15, 718787259) '&H2AD7D2BBMD5_b = MD5_II(MD5_b, MD5_c, MD5_d, MD5_a, MD5_x[k + 9], 21, -343485551) '&HEB86D391MD5_a = MD5_a + MD5_AAMD5_b = MD5_b + MD5_BBMD5_c = MD5_c + MD5_CCMD5_d = MD5_d + MD5_DDNextReturn (WordToHex(MD5_a) + WordToHex(MD5_b) + WordToHex(MD5_c) + WordToHex(MD5_d)).ToUpper()End FunctionFunction MD5_F:Int(x:Int, y:Int, z:Int)Return ((x & y) | (~(x) & z))End FunctionFunction MD5_G:Int(x:Int, y:Int, z:Int)Return ((x & z) | (y & (~(z))))End FunctionFunction MD5_H:Int(x:Int, y:Int, z:Int)Return (x ~ y ~ z)End FunctionFunction MD5_I:Int(x:Int, y:Int, z:Int)Return (y ~ (x | (~z)))End FunctionFunction MD5_FF:Int(a:Int, b:Int, c:Int, d:Int, x:Int, s:Int, ac:Int)a = (a + ((MD5_F(b, c, d)+ x)+ ac))a = RotateLeft(a, s)Return a + bEnd FunctionFunction MD5_GG:Int(a:Int, b:Int, c:Int, d:Int, x:Int, s:Int, ac:Int)a = (a + ((MD5_G(b, c, d) + x) + ac))a = RotateLeft(a, s)Return a + bEnd FunctionFunction MD5_HH:Int(a:Int, b:Int, c:Int, d:Int, x:Int, s:Int, ac:Int)a = (a + ((MD5_H(b, c, d) + x) + ac))a = RotateLeft(a, s)Return a + bEnd FunctionFunction MD5_II:Int(a:Int, b:Int, c:Int, d:Int, x:Int, s:Int, ac:Int)a = (a + ((MD5_I(b, c, d) + x) + ac))a = RotateLeft(a, s)Return a + bEnd FunctionFunction RotateLeft:Int(lValue:Int, iShiftBits:Int)Return (lValue Shl iShiftBits) | (lValue Shr (32 - iShiftBits))End FunctionFunction WordToHex:String(lValue:Int)Local returnString:StringreturnString = ULongToString(lValue,16)Return returnString.Slice(6,8) + returnString.Slice(4,6) + returnString.Slice(2,4) + returnString.Slice(0,2)End FunctionI was trying to convert the first link example(http://wasted.nz/codearcs.php?code=1449)but apparently the slice function doesn’t work with non strings:
[/crayon]Monkey12345678[crayon-5cb9b30237b3c419033096 inline="true" ]Function Main()Local a:Int[] = New Int[](9,8,7,6,5,4,3,2,1)Local b := a.Slice(2,2)Print b.LengthPrint b[0]+" "+b[1]End Functionthis gives me an error. “Index out of Range”.
that’s the only thing that stops me from finishing it.
December 20, 2017 at 4:27 am #12380Slice (2,2) will return a 0 length string, which will cause an array index error if you try and index it.
December 20, 2017 at 4:57 am #12381Oh!
I get it now. Really misunderstood the concept. I thought that it meant from character 2 slice 2 characters.
I’ll post the code in a while.December 20, 2017 at 5:27 am #12382I think this one is for you Mark.
this is what I came out with:[/crayon]Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237[crayon-5cb9b3026ffe2802158454 inline="true" ]#Import "<std>"Using std..'====================================== TEST ======================================Function Main()Print ""Print "==== MD5 ===="Print MD5("The quick brown fox jumps over the lazy dog")Print "9e107d9d372bb6826bd81d3542a419d6 <- Should be this"Print ""Print "===== SHA-1 ====="Print SHA1("The quick brown fox jumps over the lazy dog")Print "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 <- Should be this"Print ""Print "===== SHA-256 ====="Print SHA256("The quick brown fox jumps over the lazy dog")Print "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592 <- Should be this"End Function''====================================== TEST ======================================Function MD5:String(in:String)Local h0:Int = $67452301, h1:Int = $EFCDAB89, h2:Int = $98BADCFE, h3:Int = $10325476Local r:Int[] = New Int[](7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21)Local k:Int[] = New Int[]($D76AA478, $E8C7B756, $242070DB, $C1BDCEEE, $F57C0FAF, $4787C62A,$A8304613, $FD469501, $698098D8, $8B44F7AF, $FFFF5BB1, $895CD7BE,$6B901122, $FD987193, $A679438E, $49B40821, $F61E2562, $C040B340,$265E5A51, $E9B6C7AA, $D62F105D, $02441453, $D8A1E681, $E7D3FBC8,$21E1CDE6, $C33707D6, $F4D50D87, $455A14ED, $A9E3E905, $FCEFA3F8,$676F02D9, $8D2A4C8A, $FFFA3942, $8771F681, $6D9D6122, $FDE5380C,$A4BEEA44, $4BDECFA9, $F6BB4B60, $BEBFBC70, $289B7EC6, $EAA127FA,$D4EF3085, $04881D05, $D9D4D039, $E6DB99E5, $1FA27CF8, $C4AC5665,$F4292244, $432AFF97, $AB9423A7, $FC93A039, $655B59C3, $8F0CCC92,$FFEFF47D, $85845DD1, $6FA87E4F, $FE2CE6E0, $A3014314, $4E0811A1,$F7537E82, $BD3AF235, $2AD7D2BB, $EB86D391)Local intCount:Int = (((in.Length + 8) Shr 6) + 1) Shl 4Local data:Int[] = New Int[intCount]For Local c:Int=0 Until in.Lengthdata[c Shr 2] = data[c Shr 2] | ((in[c] & $FF) Shl ((c & 3) Shl 3))Nextdata[in.Length Shr 2] = data[in.Length Shr 2] | ($80 Shl ((in.Length & 3) Shl 3))data[data.Length - 2] = (Long(in.Length) * 8) & $FFFFFFFFdata[data.Length - 1] = (Long(in.Length) * 8) Shr 32For Local chunkStart:Int=0 Until intCount Step 16Local a:Int = h0, b:Int = h1, c:Int = h2, d:Int = h3For Local i:Int=0 To 15Local f:Int = d ~ (b & (c ~ d))Local t:Int = dd = c ; c = bb = Rol((a + f + k[i] + data[chunkStart + i]), r[i]) + ba = tNextFor Local i:Int=16 To 31Local f:Int = c ~ (d & (b ~ c))Local t:Int = dd = c ; c = bb = Rol((a + f + k[i] + data[chunkStart + (((5 * i) + 1) & 15)]), r[i]) + ba = tNextFor Local i:Int=32 To 47Local f:Int = b ~ c ~ dLocal t:Int = dd = c ; c = bb = Rol((a + f + k[i] + data[chunkStart + (((3 * i) + 5) & 15)]), r[i]) + ba = tNextFor Local i:Int=48 To 63Local f:Int = c ~ (b | ~d)Local t:Int = dd = cc = bb = Rol((a + f + k[i] + data[chunkStart + ((7 * i) & 15)]), r[i]) + ba = tNexth0 += ah1 += bh2 += ch3 += dNextReturn (LEHex(h0) + LEHex(h1) + LEHex(h2) + LEHex(h3)).ToLower()End FunctionFunction SHA1:String(in:String)Local h0:Int = $67452301, h1:Int = $EFCDAB89, h2:Int = $98BADCFE, h3:Int = $10325476, h4:Int = $C3D2E1F0Local intCount:Int = (((in.Length + 8) Shr 6) + 1) Shl 4Local data:Int[] = New Int[intCount]For Local c:Int=0 Until in.Lengthdata[c Shr 2] = (data[c Shr 2] Shl 8) | (in[c] & $FF)Nextdata[in.Length Shr 2] = ((data[in.Length Shr 2] Shl 8) | $80) Shl ((3 - (in.Length & 3)) Shl 3)data[data.Length - 2] = (Long(in.Length) * 8) Shr 32data[data.Length - 1] = (Long(in.Length) * 8) & $FFFFFFFFFor Local chunkStart:Int=0 Until intCount Step 16Local a:Int = h0, b:Int = h1, c:Int = h2, d:Int = h3, e:Int = h4Local w := data.Slice(chunkStart,chunkStart + 16)w = w.Slice(0,80)For Local i:Int=16 To 79w[i] = Rol(w[i - 3] ~ w[i - 8] ~ w[i - 14] ~ w[i - 16], 1)NextFor Local i:Int=0 To 19Local t:Int = Rol(a, 5) + (d ~ (b & (c ~ d))) + e + $5A827999 + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNextFor Local i:Int=20 To 39Local t:Int = Rol(a, 5) + (b ~ c ~ d) + e + $6ED9EBA1 + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNextFor Local i:Int=40 To 59Local t:Int = Rol(a, 5) + ((b & c) | (d & (b | c))) + e + $8F1BBCDC + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNextFor Local i:Int=60 To 79Local t:Int = Rol(a, 5) + (b ~ c ~ d) + e + $CA62C1D6 + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNexth0 += ah1 += bh2 += ch3 += dh4 += eNextReturn (Hex(h0) + Hex(h1) + Hex(h2) + Hex(h3) + Hex(h4)).ToLower()End FunctionFunction SHA256:String(in:String)Local h0:Int = $6A09E667, h1:Int = $BB67AE85, h2:Int = $3C6EF372, h3:Int = $A54FF53ALocal h4:Int = $510E527F, h5:Int = $9B05688C, h6:Int = $1F83D9AB, h7:Int = $5BE0CD19Local k:Int[] = New Int[]($428A2F98, $71374491, $B5C0FBCF, $E9B5DBA5, $3956C25B, $59F111F1,$923F82A4, $AB1C5ED5, $D807AA98, $12835B01, $243185BE, $550C7DC3,$72BE5D74, $80DEB1FE, $9BDC06A7, $C19BF174, $E49B69C1, $EFBE4786,$0FC19DC6, $240CA1CC, $2DE92C6F, $4A7484AA, $5CB0A9DC, $76F988DA,$983E5152, $A831C66D, $B00327C8, $BF597FC7, $C6E00BF3, $D5A79147,$06CA6351, $14292967, $27B70A85, $2E1B2138, $4D2C6DFC, $53380D13,$650A7354, $766A0ABB, $81C2C92E, $92722C85, $A2BFE8A1, $A81A664B,$C24B8B70, $C76C51A3, $D192E819, $D6990624, $F40E3585, $106AA070,$19A4C116, $1E376C08, $2748774C, $34B0BCB5, $391C0CB3, $4ED8AA4A,$5B9CCA4F, $682E6FF3, $748F82EE, $78A5636F, $84C87814, $8CC70208,$90BEFFFA, $A4506CEB, $BEF9A3F7, $C67178F2)Local intCount:Int = (((in.Length + 8) Shr 6) + 1) Shl 4Local data:Int[] = New Int[intCount]For Local c:Int=0 Until in.Lengthdata[c Shr 2] = (data[c Shr 2] Shl 8) | (in[c] & $FF)Nextdata[in.Length Shr 2] = ((data[in.Length Shr 2] Shl 8) | $80) Shl ((3 - (in.Length & 3)) Shl 3)data[data.Length - 2] = (Long(in.Length) * 8) Shr 32data[data.Length - 1] = (Long(in.Length) * 8) & $FFFFFFFFFor Local chunkStart:Int=0 Until intCount Step 16Local a:Int = h0, b:Int = h1, c:Int = h2, d:Int = h3, e:Int = h4, f:Int = h5, g:Int = h6, h:Int = h7Local w := data.Slice(chunkStart,chunkStart + 16)w = w.Slice(0,64)For Local i:Int=16 To 63w[i] = w[i - 16] + (Ror(w[i - 15], 7) ~ Ror(w[i - 15], 18) ~ (w[i - 15] Shr 3))+w[i - 7] + (Ror(w[i - 2], 17) ~ Ror(w[i - 2], 19) ~ (w[i - 2] Shr 10))NextFor Local i:Int=0 To 63Local t0:Int = (Ror(a, 2) ~ Ror(a, 13) ~ Ror(a, 22)) + ((a & b) | (b & c) | (c & a))Local t1:Int = h + (Ror(e, 6) ~ Ror(e, 11) ~ Ror(e, 25)) + ((e & f) | (~e & g)) + k[i] + w[i]h = g ; g = f ; f = e ; e = d + t1d = c ; c = b ; b = a ; a = t0 + t1Nexth0 += a ; h1 += b ; h2 += c ; h3 += dh4 += e ; h5 += f ; h6 += g ; h7 += hNextReturn (Hex(h0) + Hex(h1) + Hex(h2) + Hex(h3) + Hex(h4) + Hex(h5) + Hex(h6) + Hex(h7)).ToLower()End FunctionFunction Hex:String(val:Int)Return ULongToString(val,16)End FunctionFunction Rol:Int(val:Int, shift:Int)Return (val Shl shift) | (val Shr (32 - shift))End FunctionFunction Ror:Int(val:Int, shift:Int)Return (val Shr shift) | (val Shl (32 - shift))End FunctionFunction LEHex:String(val:Int)Local out:String = Hex(val)Return out.Slice(6,8) + out.Slice(4,6) + out.Slice(2,4) + out.Slice(0,2)End FunctionBut when I run it, I get this error.:
Parsing…
Semanting…
Translating…
Compiling…
Build error: System command failed:g++ -c -std=c++14 -mmacosx-version-min=10.9 -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality -I”/Users/jesse/monkey2/modules/” -I”/Users/jesse/monkey2/modules/monkey/native” -I”/Users/jesse/monkey2/tmp/” -DBB_NEWREFLECTION -I”/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/build/” -o “/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/build/untitled3_0untitled3.cpp.o” “/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp”
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:48: error: constant expression evaluates to 3049323471 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:48: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:59: error: constant expression evaluates to 3921009573 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:59: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:91: error: constant expression evaluates to 2453635748 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:91: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:102: error: constant expression evaluates to 2870763221 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:102: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:113: error: constant expression evaluates to 3624381080 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:113: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:166: error: constant expression evaluates to 2162078206 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:166: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:177: error: constant expression evaluates to 2614888103 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:177: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:188: error: constant expression evaluates to 3248222580 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:188: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:199: error: constant expression evaluates to 3835390401 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:199: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:210: error: constant expression evaluates to 4022224774 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:210: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:284: error: constant expression evaluates to 2554220882 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:284: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:295: error: constant expression evaluates to 2821834349 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:295: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:306: error: constant expression evaluates to 2952996808 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:306: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:317: error: constant expression evaluates to 3210313671 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:317: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:328: error: constant expression evaluates to 3336571891 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:328: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:339: error: constant expression evaluates to 3584528711 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:339: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:434: error: constant expression evaluates to 2177026350 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:434: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:445: error: constant expression evaluates to 2456956037 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:445: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:456: error: constant expression evaluates to 2730485921 which cannot be narrowed to type ‘int’ [-Wc++11-narrowing]
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
/Users/jesse/monkey2/tmp/untitled3.buildv1.1.09/macos_debug/src/untitled3_untitled3.cpp:77:456: note: insert an explicit cast to silence this issue
f0.l_k=bbArray<bbInt>({1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298},64);
^~~~~~~~~~
static_cast<int>( )
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.***** Fatal mx2cc error *****
Internal mx2cc build error
December 22, 2017 at 9:00 am #12405Nice work!
Some compiler fixes for the numeric errors above have been pushe to the develop branch.
Also, I had to do some tweaking to the code above, the main issue being that ‘Shr’ in mx2 is signed/unsigned depending on whether LHS is signed/unsigned (like C/C++) whereas in BMX Shr is signed and Sar is unsigned. So I rolled a little unsigned Shr (UShr) function which I may end up adding to the language as an operator…?
New code below, will add it to std soon (in std.digest?):
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241#Import "<std>"Using std..'====================================== TEST ======================================Function Main()Print ""Print "==== MD5 ===="Print MD5("The quick brown fox jumps over the lazy dog")Print "9e107d9d372bb6826bd81d3542a419d6 <- Should be this"Print ""Print "===== SHA-1 ====="Print SHA1("The quick brown fox jumps over the lazy dog")Print "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 <- Should be this"Print ""Print "===== SHA-256 ====="Print SHA256("The quick brown fox jumps over the lazy dog")Print "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592 <- Should be this"End Function''====================================== TEST ======================================Function MD5:String(in:String)Local h0:Int = $67452301, h1:Int = $EFCDAB89, h2:Int = $98BADCFE, h3:Int = $10325476Local r:Int[] = New Int[](7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21)Local k:Int[] = New Int[]($D76AA478, $E8C7B756, $242070DB, $C1BDCEEE, $F57C0FAF, $4787C62A,$A8304613, $FD469501, $698098D8, $8B44F7AF, $FFFF5BB1, $895CD7BE,$6B901122, $FD987193, $A679438E, $49B40821, $F61E2562, $C040B340,$265E5A51, $E9B6C7AA, $D62F105D, $02441453, $D8A1E681, $E7D3FBC8,$21E1CDE6, $C33707D6, $F4D50D87, $455A14ED, $A9E3E905, $FCEFA3F8,$676F02D9, $8D2A4C8A, $FFFA3942, $8771F681, $6D9D6122, $FDE5380C,$A4BEEA44, $4BDECFA9, $F6BB4B60, $BEBFBC70, $289B7EC6, $EAA127FA,$D4EF3085, $04881D05, $D9D4D039, $E6DB99E5, $1FA27CF8, $C4AC5665,$F4292244, $432AFF97, $AB9423A7, $FC93A039, $655B59C3, $8F0CCC92,$FFEFF47D, $85845DD1, $6FA87E4F, $FE2CE6E0, $A3014314, $4E0811A1,$F7537E82, $BD3AF235, $2AD7D2BB, $EB86D391)Local intCount:Int = (((in.Length + 8) Shr 6) + 1) Shl 4Local data:Int[] = New Int[intCount]For Local c:Int=0 Until in.Lengthdata[c Shr 2] = data[c Shr 2] | ((in[c] & $FF) Shl ((c & 3) Shl 3))Nextdata[in.Length Shr 2] = data[in.Length Shr 2] | ($80 Shl ((in.Length & 3) Shl 3))data[data.Length - 2] = (Long(in.Length) * 8) & $FFFFFFFFdata[data.Length - 1] = (Long(in.Length) * 8) Shr 32For Local chunkStart:Int=0 Until intCount Step 16Local a:Int = h0, b:Int = h1, c:Int = h2, d:Int = h3For Local i:Int=0 To 15Local f:Int = d ~ (b & (c ~ d))Local t:Int = dd = c ; c = bb = Rol((a + f + k[i] + data[chunkStart + i]), r[i]) + ba = tNextFor Local i:Int=16 To 31Local f:Int = c ~ (d & (b ~ c))Local t:Int = dd = c ; c = bb = Rol((a + f + k[i] + data[chunkStart + (((5 * i) + 1) & 15)]), r[i]) + ba = tNextFor Local i:Int=32 To 47Local f:Int = b ~ c ~ dLocal t:Int = dd = c ; c = bb = Rol((a + f + k[i] + data[chunkStart + (((3 * i) + 5) & 15)]), r[i]) + ba = tNextFor Local i:Int=48 To 63Local f:Int = c ~ (b | ~d)Local t:Int = dd = cc = bb = Rol((a + f + k[i] + data[chunkStart + ((7 * i) & 15)]), r[i]) + ba = tNexth0 += ah1 += bh2 += ch3 += dNextReturn (LEHex(h0) + LEHex(h1) + LEHex(h2) + LEHex(h3)).ToLower()End FunctionFunction SHA1:String(in:String)Local h0:Int = $67452301, h1:Int = $EFCDAB89, h2:Int = $98BADCFE, h3:Int = $10325476, h4:Int = $C3D2E1F0Local intCount:Int = (((in.Length + 8) Shr 6) + 1) Shl 4Local data:Int[] = New Int[intCount]For Local c:Int=0 Until in.Lengthdata[c Shr 2] = (data[c Shr 2] Shl 8) | (in[c] & $FF)Nextdata[in.Length Shr 2] = ((data[in.Length Shr 2] Shl 8) | $80) Shl ((3 - (in.Length & 3)) Shl 3)data[data.Length - 2] = (Long(in.Length) * 8) Shr 32data[data.Length - 1] = (Long(in.Length) * 8) & $FFFFFFFFFor Local chunkStart:Int=0 Until intCount Step 16Local a:Int = h0, b:Int = h1, c:Int = h2, d:Int = h3, e:Int = h4Local w := data.Slice(chunkStart,chunkStart+16).Resize(80)For Local i:Int=16 To 79w[i] = Rol(w[i - 3] ~ w[i - 8] ~ w[i - 14] ~ w[i - 16], 1)NextFor Local i:Int=0 To 19Local t:Int = Rol(a, 5) + (d ~ (b & (c ~ d))) + e + $5A827999 + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNextFor Local i:Int=20 To 39Local t:Int = Rol(a, 5) + (b ~ c ~ d) + e + $6ED9EBA1 + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNextFor Local i:Int=40 To 59Local t:Int = Rol(a, 5) + ((b & c) | (d & (b | c))) + e + $8F1BBCDC + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNextFor Local i:Int=60 To 79Local t:Int = Rol(a, 5) + (b ~ c ~ d) + e + $CA62C1D6 + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNexth0 += ah1 += bh2 += ch3 += dh4 += eNextReturn (Hex(h0) + Hex(h1) + Hex(h2) + Hex(h3) + Hex(h4)).ToLower()End FunctionFunction SHA256:String(in:String)Local h0:Int = $6A09E667, h1:Int = $BB67AE85, h2:Int = $3C6EF372, h3:Int = $A54FF53ALocal h4:Int = $510E527F, h5:Int = $9B05688C, h6:Int = $1F83D9AB, h7:Int = $5BE0CD19Local k:Int[] = New Int[]($428A2F98, $71374491, $B5C0FBCF, $E9B5DBA5, $3956C25B, $59F111F1,$923F82A4, $AB1C5ED5, $D807AA98, $12835B01, $243185BE, $550C7DC3,$72BE5D74, $80DEB1FE, $9BDC06A7, $C19BF174, $E49B69C1, $EFBE4786,$0FC19DC6, $240CA1CC, $2DE92C6F, $4A7484AA, $5CB0A9DC, $76F988DA,$983E5152, $A831C66D, $B00327C8, $BF597FC7, $C6E00BF3, $D5A79147,$06CA6351, $14292967, $27B70A85, $2E1B2138, $4D2C6DFC, $53380D13,$650A7354, $766A0ABB, $81C2C92E, $92722C85, $A2BFE8A1, $A81A664B,$C24B8B70, $C76C51A3, $D192E819, $D6990624, $F40E3585, $106AA070,$19A4C116, $1E376C08, $2748774C, $34B0BCB5, $391C0CB3, $4ED8AA4A,$5B9CCA4F, $682E6FF3, $748F82EE, $78A5636F, $84C87814, $8CC70208,$90BEFFFA, $A4506CEB, $BEF9A3F7, $C67178F2)Local intCount:Int = (((in.Length + 8) Shr 6) + 1) Shl 4Local data:Int[] = New Int[intCount]For Local c:Int=0 Until in.Lengthdata[c Shr 2] = (data[c Shr 2] Shl 8) | (in[c] & $FF)Nextdata[in.Length Shr 2] = ((data[in.Length Shr 2] Shl 8) | $80) Shl ((3 - (in.Length & 3)) Shl 3)data[data.Length - 2] = (Long(in.Length) * 8) Shr 32data[data.Length - 1] = (Long(in.Length) * 8) & $FFFFFFFFFor Local chunkStart:Int=0 Until intCount Step 16Local a:Int = h0, b:Int = h1, c:Int = h2, d:Int = h3, e:Int = h4, f:Int = h5, g:Int = h6, h:Int = h7Local w:=data.Slice(chunkStart,chunkStart+16).Resize(64)For Local i:Int=16 To 63w[i] = w[i - 16] + (Ror(w[i - 15], 7) ~ Ror(w[i - 15], 18) ~ ( UShr(w[i - 15],3) ))+w[i - 7] + (Ror(w[i - 2], 17) ~ Ror(w[i - 2], 19) ~ ( UShr(w[i - 2],10) ))' w[i] = w[i - 16] + (Ror(w[i - 15], 7) ~ Ror(w[i - 15], 18) ~ (w[i - 15] Shr 3))+' w[i - 7] + (Ror(w[i - 2], 17) ~ Ror(w[i - 2], 19) ~ (w[i - 2] Shr 10))NextFor Local i:Int=0 To 63Local t0:Int = (Ror(a, 2) ~ Ror(a, 13) ~ Ror(a, 22)) + ((a & b) | (b & c) | (c & a))Local t1:Int = h + (Ror(e, 6) ~ Ror(e, 11) ~ Ror(e, 25)) + ((e & f) | (~e & g)) + k[i] + w[i]h = g ; g = f ; f = e ; e = d + t1d = c ; c = b ; b = a ; a = t0 + t1Nexth0 += a ; h1 += b ; h2 += c ; h3 += dh4 += e ; h5 += f ; h6 += g ; h7 += hNextReturn (Hex(h0) + Hex(h1) + Hex(h2) + Hex(h3) + Hex(h4) + Hex(h5) + Hex(h6) + Hex(h7)).ToLower()End FunctionFunction Hex:String(val:UInt)Local hex:=("00000000"+ULongToString(val,16)).Right(8)Return hexEnd FunctionFunction Rol:UInt(val:UInt, shift:Int)Return (val Shl shift) | (val Shr (32 - shift))End FunctionFunction Ror:UInt(val:UInt, shift:Int)Return (val Shr shift) | (val Shl (32 - shift))End FunctionFunction UShr:UInt(val:UInt, shift:Int)Return val Shr shiftEndFunction LEHex:String(val:UInt)Local out:String = Hex(val)Return out.Slice(6,8) + out.Slice(4,6) + out.Slice(2,4) + out.Slice(0,2)End FunctionDecember 22, 2017 at 11:37 am #12410Reading that code made my head hurt.
-
AuthorPosts
You must be logged in to reply to this topic.