from matasano.util.byte_xor import byte_list_xor
import sys

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage:\n\t python -m example.py <string to encrypt>")
        quit()

    input_str = sys.argv[1]

    # Convert string to list of bytes
    byte_list_input = [ord(c) for c in input_str]

    # XOR the string with the byte 1 (flips last bit)
    output_list = byte_list_xor(byte_list_input, [1]*len(input_str))

    # Convert list back to string
    output_str = "".join(chr(b) for b in output_list)

    print("The encrypted string is: {}".format(output_str))
from matasano.util.byte_xor import byte_list_xor
import sys

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage:\n\t python -m example.py <string to encrypt>")
        quit()

    input_str = sys.argv[1]

    # Convert string to list of bytes
    byte_list_input = [ord(c) for c in input_str]

    # XOR the string with the byte 2 (flips secondd last bit)
    output_list = byte_list_xor(byte_list_input, [2]*len(input_str))

    # Convert list back to string
    output_str = "".join(chr(b) for b in output_list)

    print("The encrypted string is: {}".format(output_str))
Change XOR to flip second last bit
Change XOR to flip second last bit

Making change to cause merge conflict as an example.

  from matasano.util.byte_xor import byte_list_xor
  import sys
  
  if __name__ == "__main__":
      if len(sys.argv) != 2:
          print("Usage:\n\t python -m example.py <string to encrypt>")
          quit()
  
      input_str = sys.argv[1]
  
      # Convert string to list of bytes
      byte_list_input = [ord(c) for c in input_str]
  
-     # XOR the string with the byte 1 (flips last bit)
+     # XOR the string with the byte 2 (flips secondd last bit)
-     output_list = byte_list_xor(byte_list_input, [1]*len(input_str))
+     output_list = byte_list_xor(byte_list_input, [2]*len(input_str))
  
      # Convert list back to string
      output_str = "".join(chr(b) for b in output_list)
  
      print("The encrypted string is: {}".format(output_str))
Change XOR to flip second last bit
## Code Before:
from matasano.util.byte_xor import byte_list_xor
import sys

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage:\n\t python -m example.py <string to encrypt>")
        quit()

    input_str = sys.argv[1]

    # Convert string to list of bytes
    byte_list_input = [ord(c) for c in input_str]

    # XOR the string with the byte 1 (flips last bit)
    output_list = byte_list_xor(byte_list_input, [1]*len(input_str))

    # Convert list back to string
    output_str = "".join(chr(b) for b in output_list)

    print("The encrypted string is: {}".format(output_str))
## Instruction:
Change XOR to flip second last bit
## Code After:
from matasano.util.byte_xor import byte_list_xor
import sys

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage:\n\t python -m example.py <string to encrypt>")
        quit()

    input_str = sys.argv[1]

    # Convert string to list of bytes
    byte_list_input = [ord(c) for c in input_str]

    # XOR the string with the byte 2 (flips secondd last bit)
    output_list = byte_list_xor(byte_list_input, [2]*len(input_str))

    # Convert list back to string
    output_str = "".join(chr(b) for b in output_list)

    print("The encrypted string is: {}".format(output_str))