Skip to content

Commit d941ea6

Browse files
Some strings salting and expanding
1 parent 0f7e299 commit d941ea6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/YASL/Hashing/ChgString.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package YASL.Hashing;
22

3+
import java.nio.charset.StandardCharsets;
4+
35
public class ChgString implements IHashingGenerator<String> {
46
private final IHashingGenerator<byte[]> _gen;
57

@@ -16,14 +18,20 @@ private static byte[] rotateBytes(byte[] src, int round) {
1618
round %= src.length;
1719
System.arraycopy(src, 0, res, round, src.length - round);
1820
System.arraycopy(src, src.length - round, res, 0, round);
21+
for (int i = 0; i < res.length; i++) {
22+
res[i] = (byte) ((res[i] + i) & 0xFF);
23+
}
1924
return res;
2025
}
2126

2227
@Override
2328
public IHasher<String> generate(int range, int levels) {
2429
IHasher<byte[]> hashing = _gen.generate(range, levels);
2530
return x -> {
26-
return hashing.apply(x.getBytes());
31+
while (x.length() < 16) {
32+
x += x;
33+
}
34+
return hashing.apply(x.getBytes(StandardCharsets.UTF_8));
2735
};
2836
}
2937

0 commit comments

Comments
 (0)