MCPcopy Index your code
hub / github.com/SeanDragon/protools / padding

Method padding

security/src/main/java/pro/tools/security/sm/SM3.java:69–85  ·  view source on GitHub ↗
(byte[] source)

Source from the content-addressed store, hash-verified

67 }
68
69 private static byte[] padding(byte[] source) throws IOException {
70 long l = source.length * 8;
71 long k = 448 - (l + 1) % 512;
72 if (k < 0) {
73 k = k + 512;
74 }
75 ByteArrayOutputStream baos = new ByteArrayOutputStream();
76 baos.write(source);
77 baos.write(FirstPadding);
78 long i = k - 7;
79 while (i > 0) {
80 baos.write(ZeroPadding);
81 i -= 8;
82 }
83 baos.write(long2bytes(l));
84 return baos.toByteArray();
85 }
86
87 private static byte[] long2bytes(long l) {
88 byte[] bytes = new byte[8];

Callers 1

hashMethod · 0.95

Calls 3

long2bytesMethod · 0.95
writeMethod · 0.80
toByteArrayMethod · 0.80

Tested by

no test coverage detected