Created
February 15, 2016 18:54
-
-
Save latsku/9d0901a1ffb03492ada2 to your computer and use it in GitHub Desktop.
A Mathematica package to calculate SHA-2 constants
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
(* ::Package:: *) | |
(* ::Input:: *) | |
(* SHA-2 Constant calculator | |
Calculation of SHA-2 uses a group of precomputed constants as part of the hash calculation. These numbers are pregiven on the standard, but also explained to come from fractional part of a cube root of primes. This notebook calculates these constants. | |
Source: http://dx.doi.org/10.6028/NIST.FIPS.180-4 | |
*) | |
(* ::Input:: *) | |
(* SHA-224 & SHA-256 Constants *) | |
Table[ | |
StringTake[ToString[ | |
BaseForm[ | |
N[ | |
FractionalPart[CubeRoot[Prime[n]]], | |
32], | |
16]], | |
{3,10}], | |
{n,64}] | |
(* ::Input:: *) | |
(* SHA-384 & SHA-512 Constants *) | |
Table[ | |
StringTake[ToString[ | |
BaseForm[ | |
N[ | |
FractionalPart[CubeRoot[Prime[n]]], | |
64], | |
16]], | |
{3,18}], | |
{n,80}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment