tlsrestrict: Added documentation to Sleeve256.

pull/21/head
JeremyRand 7 years ago
parent fa20ab1f9a
commit 4e32f268df
No known key found for this signature in database
GPG Key ID: B3F2D165786D6570

@ -52,6 +52,9 @@ func BlockAllCAs() (map[string]interface{}, error) {
return rule, nil
}
// Calculates floor(2**256/pi), and encodes the result as base64.
// Intended to be used as a SHA256 hash where I don't have a preimage up my sleeve.
// Python2 version originally by Ryan Castellucci. Go port, pi sourcing, and base64 output by Jeremy Rand.
func Sleeve256() (string, error) {
var pi big.Float
var exp256Float big.Float

@ -24,6 +24,8 @@ func TestSleeve256(t *testing.T) {
t.Error(err)
}
// To reproduce this with web-based tools, use https://www.wolframalpha.com/input/?i=hex%28floor%282^256%2Fpi%29%29
// and then convert from hex to base64 via https://holtstrom.com/michael/tools/hextopem.php
reference := "UXzBtyciCpT+E6vo+ppu4G2xSsyeIcgg/yix1e9d4rA="
if sleeve != reference {

Loading…
Cancel
Save