You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicstaticLayerIdofSha256Digest(byte[] digest) {
Assert.notNull(digest, "Digest must not be null");
Assert.isTrue(digest.length == 32, "Digest must be exactly 32 bytes");
Stringalgorithm = "sha256";
Stringhash = String.format("%32x", newBigInteger(1, digest));
returnnewLayerId(algorithm + ":" + hash, algorithm, hash);
}
%32x is actually only guaranteed to be at least 32 characters. We need 64. So sometimes we get 63 because the content of the digest has a low leading byte value. This would probably work (because Java Formatter pads with spaces not zeros, and docker wants zeros):
String hash = String.format("%64x", new BigInteger(1, digest)).replace(" ", "0");
The text was updated successfully, but these errors were encountered:
wilkinsona
changed the title
Ensure digest hashes are zero padded to 64 characters
Image building support does not zero-pad digest hashes to 64 characters
Sep 17, 2020
Uh oh!
There was an error while loading. Please reload this page.
Split from #23130
%32x
is actually only guaranteed to be at least 32 characters. We need 64. So sometimes we get 63 because the content of the digest has a low leading byte value. This would probably work (because JavaFormatter
pads with spaces not zeros, and docker wants zeros):The text was updated successfully, but these errors were encountered: