Skip to content

Commit

Permalink
Update steganopy.py
Browse files Browse the repository at this point in the history
Changed 'key' variable for encrypting and decrypting to allow for strings to be passed as a key instead of just integers.
  • Loading branch information
irtsa-dev committed Sep 28, 2024
1 parent de81803 commit 6191b76
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Steganopy/steganopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
SteganodecryptParser.add_argument('source', help = 'Picture source location.')
SteganodecryptParser.add_argument('-v', '--values', help = 'Values to be used for decryption.', default = 'rgb')
SteganodecryptParser.add_argument('-e', '--encoding', help = 'Specifies the base the information is encoded in.', default = 'binary')
SteganodecryptParser.add_argument('-k', '--key', type = int, help = 'Specifies key to use for xor operation.')
SteganodecryptParser.add_argument('-k', '--key', help = 'Specifies key to use for xor operation.')
SteganodecryptParser.add_argument('-o', '--output', help = 'Specifies output file name.')


Expand All @@ -57,7 +57,8 @@ def baseConvert(number: int, base: int):
return ''.join([str(i) for i in digits[::-1]])


def expandKey(key: int, length: int, base: int) -> str:
def expandKey(key: str, length: int, base: int) -> str:
key = int(''.join([str(ord(i)) for i in key]))
if key < 2: error('ValueError', 'Argument "key" must be greater than 2.')
while len(baseConvert(key, base)) < length: key *= key
return baseConvert(key, base)[0:length]
Expand Down Expand Up @@ -100,7 +101,7 @@ def getEncodingInformation(base: str):


#Encrypt Command Function
def Encrypt(text: str, fileTextSource: str, ValueIndexes: list, ImageInformation: list, EncodingInformation: list, key: int, outputName: str):
def Encrypt(text: str, fileTextSource: str, ValueIndexes: list, ImageInformation: list, EncodingInformation: list, key: str, outputName: str):
if text is not None and fileTextSource is not None: Error('ValueError', 'Cannot have "file" and "text" arguments both be in use.')

validImage, imageSource, imageName, imagePath = ImageInformation
Expand Down

0 comments on commit 6191b76

Please sign in to comment.