Last active
September 11, 2021 04:04
-
-
Save dieseltravis/727202f3a259391d6e73ebf87fd3f380 to your computer and use it in GitHub Desktop.
find 10-digit primes in verious hash values
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
// this doesn't work: | |
/* | |
h = this.GetHash(); | |
x = {last 10-digit prime found in consecutive digits of h in base-10}; | |
requests.post('https://api.alpaca.markets/v2/puzzle/202108/solve', json={'answer': account.id.int * x, 'email': your_waitlist_email}) | |
*/ | |
// get basic hashes with Powershell | |
//@('SHA1', 'SHA256', 'SHA384', 'SHA512', 'MD5') | % { Get-FileHash -Path ~\Downloads\110-days-after-lehman-collapsed.jpg -Algorithm "$_" } | |
// ImageMagick hash: | |
//. "C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\identify.exe" -format '%# - %f\n' ~\Downloads\110-days-after-lehman-collapsed.jpg | |
// also tried X-Amz-Signature value from http headers | |
const bigInt = require("big-integer"); | |
// use this to convert from large hex to decimal https://github.com/peterolson/BigInteger.js | |
const hashes = [ | |
{ | |
alg: "SHA1", | |
hex: "2BAFE2C0E8AF9E5ABD56BCDA3A55D496273BCE17", | |
dec: "249408986575295744009914666315845831158409186839" | |
}, | |
{ | |
alg: "SHA256", | |
hex: "E0276B7C5F623E1610E9DF33A2B10B515CB0C3E05DD5C0AA2C41082E839ACFD9", | |
dec: "101387726958115603640319954397403484634240812068163599832991394802643337138137" | |
}, | |
{ | |
alg: "SHA384", | |
hex: "05F7F69B955E85570332C562F6758E15A1A71F0A2C1AF4430E6E5DCB5D4C7E68FE69182E6F498BCD768FCECF1B0B3DD1", | |
dec: "918652646914571849255467505039698664662139790706186520539437121925804428578886844694500572288269682399949202603473" | |
}, | |
{ | |
alg: "SHA512", | |
hex: "8280CCEE0F69F2DE62094CCA27BA254B7C188482990D159615FE11CBDE16DB315DB932642B23F80E488C1B9DA4A97A1D1F3AB55F78B9F3DBEE09F20EFA07E6F3", | |
dec: "6835003362647552627817971818993474412315985556180882395915956782319223457691858843283853858451995615042777221820623823598132413607865876816044271272978163" | |
}, | |
{ | |
alg: "MD5", | |
hex: "CD4E0E329E778C3B4EBE7660DF6292F0", | |
dec: "272897026255059203286554907578334352112" | |
}, | |
{ | |
alg: "ImageMagick", | |
hex: "34de8225a44a0b296fd1f71d8991e91e35892c6232070b34d8398d31660363ef", | |
dec: "23913406416555438578821688986402523302099110721159753338993699528059130176495" | |
}, | |
{ | |
alg: "X-Amz-Signature", | |
hex: "3a3a8eb488cbc41f3f29a3b9f3e2f91e2899990faae66fabaaef56f9ea6148e9", | |
dec: "26337607262764537343145012260433185439051242925309303714317969673949875882217" | |
} | |
]; | |
const getPrime = function (newDigits) { | |
// get ten digit numbers | |
let tens = []; | |
for (let i = newDigits.length - 10; i >= 0; i--) { | |
tens.push(newDigits.substring(i, i + 10)); | |
} | |
const isPrime = num => { | |
for(let i = 2, s = Math.sqrt(num); i <= s; i++) { | |
if(num % i === 0) { | |
return false; | |
} | |
} | |
return num > 1; | |
}; | |
let tensPrime = []; | |
for(let i = 0, l = tens.length; i < l; i++) { | |
let item = tens[i]; | |
if (item.startsWith("0")) { | |
tensPrime[i] = "skipped"; | |
} else { | |
let val = parseInt(item, 10); | |
if (isPrime(val)) { | |
tensPrime[i] = val; | |
// return first prime | |
return val; | |
} else { | |
tensPrime[i] = false; | |
} | |
} | |
} | |
}; | |
// try guid converted to decimal? | |
const acctID = new bigInt(process.env.ACCOUNT_ID_INT, 10); | |
for(let i = 0, l = hashes.length; i < l; i++) { | |
let hash = hashes[i]; | |
console.log(hash); | |
let result = getPrime(hash.dec); | |
console.log(result); | |
console.log("id:", acctID, " answer:", acctID.times(result)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment