Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

##Performance:

Performance:

def get_char(self):
 new_byte = ''
 for bit in range(0, 8):
 byte = self.fh.read(1)
 new_byte += str(ord(byte) & 0x01)
 n = int(new_byte, 2)
 desteg_char = binascii.unhexlify('%x' % n)
 desteg_char = ''.join(map(chr, desteg_char))
 return desteg_char

This is not as simple as it could be. You are reading 8 bits as strings to build a single byte, converting it to an integer, then to a hex string (string format before unhexlify), then to a hexadecimal string, then mapping to a character, and then joining them together. I recommend doing more math and less string conversion and concatenation.

Style:

1. Use consistent string delimiters

  • You have ' in most places, like open(StegImageFile, 'rb'), but you also have DELIMITER = "$" and open(StegImageFile, "wb"). Use ' everywhere if that's what you're using.

2. Remove unnecessary parentheses

  • if (s_sz != ''): should be if s_sz != '':, or even more concise: if s_sz:.

3. Consider meaningful variable names

  • s_sz isn't a helpful variable name, and I don't know what it is at a glance, other than that it's the string form of sz (also not helpful).

4. Remove the space in print (text)

  • You don't use spaces after any other function names.

5. Remove weird leading spaces

  • The space before # Consts

  • The space before import binascii

##Performance:

def get_char(self):
 new_byte = ''
 for bit in range(0, 8):
 byte = self.fh.read(1)
 new_byte += str(ord(byte) & 0x01)
 n = int(new_byte, 2)
 desteg_char = binascii.unhexlify('%x' % n)
 desteg_char = ''.join(map(chr, desteg_char))
 return desteg_char

This is not as simple as it could be. You are reading 8 bits as strings to build a single byte, converting it to an integer, then to a hex string (string format before unhexlify), then to a hexadecimal string, then mapping to a character, and then joining them together. I recommend doing more math and less string conversion and concatenation.

Style:

1. Use consistent string delimiters

  • You have ' in most places, like open(StegImageFile, 'rb'), but you also have DELIMITER = "$" and open(StegImageFile, "wb"). Use ' everywhere if that's what you're using.

2. Remove unnecessary parentheses

  • if (s_sz != ''): should be if s_sz != '':, or even more concise: if s_sz:.

3. Consider meaningful variable names

  • s_sz isn't a helpful variable name, and I don't know what it is at a glance, other than that it's the string form of sz (also not helpful).

4. Remove the space in print (text)

  • You don't use spaces after any other function names.

5. Remove weird leading spaces

  • The space before # Consts

  • The space before import binascii

Performance:

def get_char(self):
 new_byte = ''
 for bit in range(0, 8):
 byte = self.fh.read(1)
 new_byte += str(ord(byte) & 0x01)
 n = int(new_byte, 2)
 desteg_char = binascii.unhexlify('%x' % n)
 desteg_char = ''.join(map(chr, desteg_char))
 return desteg_char

This is not as simple as it could be. You are reading 8 bits as strings to build a single byte, converting it to an integer, then to a hex string (string format before unhexlify), then to a hexadecimal string, then mapping to a character, and then joining them together. I recommend doing more math and less string conversion and concatenation.

Style:

1. Use consistent string delimiters

  • You have ' in most places, like open(StegImageFile, 'rb'), but you also have DELIMITER = "$" and open(StegImageFile, "wb"). Use ' everywhere if that's what you're using.

2. Remove unnecessary parentheses

  • if (s_sz != ''): should be if s_sz != '':, or even more concise: if s_sz:.

3. Consider meaningful variable names

  • s_sz isn't a helpful variable name, and I don't know what it is at a glance, other than that it's the string form of sz (also not helpful).

4. Remove the space in print (text)

  • You don't use spaces after any other function names.

5. Remove weird leading spaces

  • The space before # Consts

  • The space before import binascii

added 651 characters in body
Source Link

I see a few possible improvements##Performance:

def get_char(self):
 new_byte = ''
 for bit in range(0, 8):
 byte = self.fh.read(1)
 new_byte += str(ord(byte) & 0x01)
 n = int(new_byte, 2)
 desteg_char = binascii.unhexlify('%x' % n)
 desteg_char = ''.join(map(chr, desteg_char))
 return desteg_char

This is not as simple as it could be. You are reading 8 bits as strings to build a single byte, converting it to an integer, then to a hex string (string format before unhexlify), then to a hexadecimal string, then mapping to a character, and then joining them together. I recommend doing more math and less string conversion and concatenation.

Style:

1. Use consistent string delimiters

  • You have ' in most places, like open(StegImageFile, 'rb'), but you also have DELIMITER = "$" and open(StegImageFile, "wb"). Use ' everywhere if that's what you're using.

2. Remove unnecessary parentheses

  • if (s_sz != ''): should be if s_sz != '':, or even more concise: if s_sz:.

3. Consider meaningful variable names

  • s_sz isn't a helpful variable name, and I don't know what it is at a glance, other than that it's the string form of sz (also not helpful).

4. Remove the space in print (text)

  • You don't use spaces after any other function names.

5. Remove weird leading spaces

  • The space before # Consts

  • The space before import binascii

I see a few possible improvements:

1. Use consistent string delimiters

  • You have ' in most places, like open(StegImageFile, 'rb'), but you also have DELIMITER = "$" and open(StegImageFile, "wb"). Use ' everywhere if that's what you're using.

2. Remove unnecessary parentheses

  • if (s_sz != ''): should be if s_sz != '':, or even more concise: if s_sz:.

3. Consider meaningful variable names

  • s_sz isn't a helpful variable name, and I don't know what it is at a glance, other than that it's the string form of sz (also not helpful).

4. Remove the space in print (text)

  • You don't use spaces after any other function names.

5. Remove weird leading spaces

  • The space before # Consts

  • The space before import binascii

##Performance:

def get_char(self):
 new_byte = ''
 for bit in range(0, 8):
 byte = self.fh.read(1)
 new_byte += str(ord(byte) & 0x01)
 n = int(new_byte, 2)
 desteg_char = binascii.unhexlify('%x' % n)
 desteg_char = ''.join(map(chr, desteg_char))
 return desteg_char

This is not as simple as it could be. You are reading 8 bits as strings to build a single byte, converting it to an integer, then to a hex string (string format before unhexlify), then to a hexadecimal string, then mapping to a character, and then joining them together. I recommend doing more math and less string conversion and concatenation.

Style:

1. Use consistent string delimiters

  • You have ' in most places, like open(StegImageFile, 'rb'), but you also have DELIMITER = "$" and open(StegImageFile, "wb"). Use ' everywhere if that's what you're using.

2. Remove unnecessary parentheses

  • if (s_sz != ''): should be if s_sz != '':, or even more concise: if s_sz:.

3. Consider meaningful variable names

  • s_sz isn't a helpful variable name, and I don't know what it is at a glance, other than that it's the string form of sz (also not helpful).

4. Remove the space in print (text)

  • You don't use spaces after any other function names.

5. Remove weird leading spaces

  • The space before # Consts

  • The space before import binascii

Source Link

I see a few possible improvements:

1. Use consistent string delimiters

  • You have ' in most places, like open(StegImageFile, 'rb'), but you also have DELIMITER = "$" and open(StegImageFile, "wb"). Use ' everywhere if that's what you're using.

2. Remove unnecessary parentheses

  • if (s_sz != ''): should be if s_sz != '':, or even more concise: if s_sz:.

3. Consider meaningful variable names

  • s_sz isn't a helpful variable name, and I don't know what it is at a glance, other than that it's the string form of sz (also not helpful).

4. Remove the space in print (text)

  • You don't use spaces after any other function names.

5. Remove weird leading spaces

  • The space before # Consts

  • The space before import binascii

lang-py

AltStyle によって変換されたページ (->オリジナル) /