Main step of GOST 28147-89: Difference between revisions
Content added Content deleted
(Updated D entry) |
(Add Nimrod) |
||
Line 397: | Line 397: | ||
In addition, the number originally entered: РB = 16, РC = 32, РD = 2048, РE = 65536. |
In addition, the number originally entered: РB = 16, РC = 32, РD = 2048, РE = 65536. |
||
=={{header|Nimrod}}== |
|||
{{trans|C}} |
|||
<lang nimrod>var |
|||
k8 = [14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7] |
|||
k7 = [15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10] |
|||
k6 = [10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8] |
|||
k5 = [ 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15] |
|||
k4 = [ 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9] |
|||
k3 = [12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11] |
|||
k2 = [ 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1] |
|||
k1 = [13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7] |
|||
k87 = newSeq[int](256) |
|||
k65 = newSeq[int](256) |
|||
k43 = newSeq[int](256) |
|||
k21 = newSeq[int](256) |
|||
proc kboxInit = |
|||
for i in 0 .. 255: |
|||
k87[i] = k8[i shr 4] shl 4 or k7[i and 15] |
|||
k65[i] = k6[i shr 4] shl 4 or k5[i and 15] |
|||
k43[i] = k4[i shr 4] shl 4 or k3[i and 15] |
|||
k21[i] = k2[i shr 4] shl 4 or k1[i and 15] |
|||
proc f(x): int = |
|||
let x = k87[x shr 24 and 255] shl 24 or k65[x shr 16 and 255] shl 16 or |
|||
k43[x shr 8 and 255] shl 8 or k21[x and 255] |
|||
x shl 11 or x shr (32 - 11)</lang> |
|||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |