package com.msbaudiosteganography.text;

/**
 *
 * @author Afina, Meisyal, Irfan
 */

public class TextProcessor {
    public String stringToBinaryString(String message) {
        String buffer = new String();
        
        for (int i = 0; i < message.length(); i++) {
            String bit = Integer.toBinaryString(message.charAt(i));
            
            if (bit.length() < 8) {
                bit = "00000000".substring(0, 8 - bit.length()).concat(bit);
            } else {
                bit = bit.substring(bit.length() - 8);
            }
            
            buffer = buffer.concat(bit);
        }
        
        return buffer;
    }
    
    public byte[] binaryStringToBytes(String binary) {
        byte[] buffer = new byte[binary.length()];
        
        for (int i = 0; i < binary.length(); i++) {
            if (binary.charAt(i) == '0') {
                buffer[i] = 0;
            } else {
                buffer[i] = 1;
            }
        }
        
        return buffer;
    }
    
    public byte[] convertBinaryStringToBytes(String message) {
        return binaryStringToBytes(stringToBinaryString(message));
    }
}

@@ -1152,10 +1152,1224 @@
 ;%0A    %7D%0A
+    %0A    public String bytesToBinaryString(byte%5B%5D byteMessage) %7B%0A        String buffer = new String();%0A        String bit;%0A        %0A        for (int i = 0; i %3C byteMessage.length; i++) %7B%0A            if (byteMessage%5Bi%5D == 0) %7B%0A                bit = %220%22;%0A            %7D else %7B%0A                bit = %221%22;%0A            %7D%0A            %0A            buffer = buffer.concat(bit);%0A        %7D%0A        %0A        return buffer;%0A    %7D%0A    %0A    public String binaryStringToText(String binaryString) %7B%0A        String text = new String();%0A        String sevenBits = new String();%0A        char symbol;%0A        %0A        for (int i = 0; i %3C binaryString.length(); i++) %7B%0A            if (binaryString.charAt(i) == '0') %7B%0A                sevenBits = sevenBits.concat(%220%22);%0A            %7D else %7B%0A                sevenBits = sevenBits.concat(%221%22);%0A            %7D%0A            %0A            if (i %25 7 == 6) %7B%0A                symbol = (char) Integer.parseInt(sevenBits, 2);%0A                text = text.concat(String.valueOf(symbol));%0A                sevenBits = %22%22;%0A            %7D %0A        %7D%0A        %0A        return  text;%0A    %7D%0A    %0A    public String removePassKey(String message) %7B%0A        return message.substring(6, message.length() - 6);%0A    %7D%0A
 %7D%0A

Add new function for text/message processing