OFFSET
1,1
COMMENTS
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, ... .
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.
The length of the input bit vector is part of the hash, so initial 0 bits will, in general, result in a different hash.
LINKS
David Rabahy, Table of n, a(n) for n = 1..1000
David Rabahy, Python program
NIST, Secure Hash Standard (SHS), FIPS PUB 180-4.
Wikipedia, SHA-2
EXAMPLE
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.
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.
PROG
(Python) # See links
(Python)
from sha256bit import Sha256bit
def a(n):
s = bin(n)[3:]
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 ""
return int(Sha256bit(t, bitlen=len(s)).hexdigest(), 16)
print([a(n) for n in range(1, 5)]) # Michael S. Branicky, Dec 08 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
David Rabahy, Dec 02 2024
STATUS
approved