cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A378628 SHA-256 hash of binary strings ordered by length then lexicographically, interpreting the bits of the resulting hash as a number in binary.

This page as a plain text file.
%I A378628 #65 Dec 22 2024 16:58:01
%S A378628 102987336249554097029535212322581322789799900648198034993379397001115665086549,
%T A378628 85627803894273957621009139791088467240572419248799306945317937552975942820725,
%U A378628 84071438648566403273885734069370854758478523414599514048347910236850479717025,91949452561369181223012808967964775320445203057864513807052896586217122700773
%N A378628 SHA-256 hash of binary strings ordered by length then lexicographically, interpreting the bits of the resulting hash as a number in binary.
%C A378628 The n-th binary string is the bits of the binary expansion of n after its most significant 1 bit, so beginning from n=1: [empty], 0, 1, 00, 01, 10, 11, 000, 001, 010, ... .
%C A378628 The SHA-256 hash function takes as input a vector of bits, possibly empty, and the resulting hash is 256 bits so that a(n) ranges 0 to 2^256-1 inclusive.
%C A378628 The length of the input bit vector is part of the hash, so initial 0 bits will, in general, result in a different hash.
%H A378628 David Rabahy, <a href="/A378628/b378628.txt">Table of n, a(n) for n = 1..1000</a>
%H A378628 David Rabahy, <a href="/A378628/a378628_2.py.txt">Python program</a>
%H A378628 NIST, Secure Hash Standard (SHS), <a href="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf">FIPS PUB 180-4</a>.
%H A378628 Wikipedia, <a href="https://en.wikipedia.org/wiki/SHA-2">SHA-2</a>
%e A378628 For n = 1, there are no bits after the most significant 1 bit, so a(1) is the SHA-256 hash of the empty string.
%e A378628 For n = 6 = 110_2, the bits after the most significant 1 are 10, so a(5) is the SHA-256 hash of the bits 10.
%o A378628 (Python) # See links
%o A378628 (Python)
%o A378628 from sha256bit import Sha256bit
%o A378628 def a(n):
%o A378628     s = bin(n)[3:]
%o A378628     t = bytearray(int(s[i*8:i*8+8].ljust(8, "0"), 2) for i in range((len(s)+7)//8)) if n > 1 else ""
%o A378628     return int(Sha256bit(t, bitlen=len(s)).hexdigest(), 16)
%o A378628 print([a(n) for n in range(1, 5)]) # Michael S. Branicky, Dec 08 2024
%Y A378628 Cf. A007931, A076478, A365749, A366061.
%K A378628 nonn
%O A378628 1,1
%A A378628 _David Rabahy_, Dec 02 2024