com.javanut.pronghorn.pipe.util.build.SecretByteSplitter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pronghorn-pipes Show documentation
Show all versions of pronghorn-pipes Show documentation
Ring buffer based queuing utility for applications that require high performance and/or a small
footprint. Well suited for embedded and stream based processing.
package com.javanut.pronghorn.pipe.util.build;
import java.io.IOException;
public class SecretByteSplitter {
public static T scramble(CharSequence source, T target) {
int i = source.length();
while (--i>=0) {
int x = (int)source.charAt(i);
if ( x<0 | x>127 ) {
throw new UnsupportedOperationException();
}
//we know that x is a small value 7 bit number
try {
target.append((char)(48+(0xF&(x>>4))));
target.append((char)(48+(0xF&x) ));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return target;
}
public static T assemble(CharSequence source, T target) {
int i = source.length();
while (--i>=0) {
int low = source.charAt(i);
int high= source.charAt(--i);
try {
target.append((char) ( ((high-48)<<4) | (low-48) ) );
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return target;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy