Must be at least 12 characters
And include at least 2 numbers
And include a symbol
A private passkey will be generated with your newly encoded image.
Decoded data will appear here!
I have listed the psudocode for the encoding and encoding algorithms. The goal is for you to learn as you code so I have been deliberately vague. I have not included how to code the call functions and would like you guys to attempt to figure this out. However, any issues, questions or hints, then don't hesitate to get in touch!
function ENCODE_PASSWORD (image,text,pw):
- USED_PIXELS = [];
- SALT = generateSalt();
- SECRETKEY = getKeyFromPassword(pw,SALT);
- STRING_BYTES = compressString(text);
- ENCRYPTED_BYTES = byteEncyption(STRING_BYTES,SECRETKEY);
- PAYLOAD = [];
- PAYLOAD_DATA = [PAYLOAD];
- BUFFER = [PAYLOAD_DATA];
- BINARY = bytesToBinary(BUFFER);
- SEED = generateSeed(pw);
- RANDOM(SEED);
- STRING_INDEX = 0;
- for STRING_INDEX to BINARY.length:
- x = RANDOM, y = RANDOM;
- PAYLOAD.append(SALT);
- PAYLOAD.append(ENCRYPTED_BYTES);
- if not contain USED_PIXELS(x,y):
- USED_PIXELS.append(x,y);
- pixel = image.getRGB(x,y);
- red = EXTRACT THE BITWISE(pixel, 16)
- green = EXTRACT THE BITWISE(pixel, 8)
- blue = EXTRACT THE BITWISE(pixel)
- while STRING_INDEX less than BINARY.length:
- setLeastSignificantBit(red, STRING_INDEX++);
- setLeastSignificantBit(green, STRING_INDEX++);
- setLeastSignificantBit(blue, STRING_INDEX++);
- newPixel = (red,green,blue)
- image = (x,y,newPixel)
RETURN image;
function ENCODE_PASSKEY (image,text,publicKey,privateKey):
- USED_PIXELS = [];
- AES_KEY = generateAESKey();
- SECRETKEY = getAESKeyFromBytes(AES_KEY);
- IV = bytes [16]
- COMPRESS_STRING = compressString(text);
- ENCRYPTED_DATA = encryptionAES(COMPRESS_STRING,SECRETKEY,IV);
- ENCRYPTED_RSA = getAESKeyWithRSA(AES_KEY,publicKey);
- PAYLOAD = [];
- PAYLOAD_DATA = [PAYLOAD];
- BUFFER = [PAYLOAD_DATA];
- BINARY = bytesToBinary(BUFFER);
- SEED = generateSeed(privateKey);
- RANDOM(SEED);
- STRING_INDEX = 0;
- PAYLOAD.append(ENCRYPTED_RSA);
- PAYLOAD.append(IV);
- PAYLOAD.append(ENCRYPTED_DATA);
- for STRING_INDEX to BINARY.length:
- x = RANDOM, y = RANDOM;
- if not contain USED_PIXELS(x,y):
- USED_PIXELS.append(x,y);
- pixel = image.getRGB(x,y);
- red = EXTRACT THE BITWISE(pixel, 16)
- green = EXTRACT THE BITWISE(pixel, 8)
- blue = EXTRACT THE BITWISE(pixel)
- while STRING_INDEX less than BINARY.length:
- setLeastSignificantBit(red, STRING_INDEX++);
- setLeastSignificantBit(green, STRING_INDEX++);
- setLeastSignificantBit(blue, STRING_INDEX++);
- newPixel = (red,green,blue)
- image = (x,y,newPixel)
RETURN image;
function DECODE_PASSWORD (image,pw):
- USED_PIXELS = [];
- ENCRYPTED_BINARY = STRING;
- ENCRYPTED_TEXT = STRING;
- SEED = generateSeed(pw)
- RANDOM = (SEED);
- START = key_word;
- END = key_word;
- DECOMPRESS_STR = STRING
- while ENCRYPTED_TEXT does not contain END:
- x = RANDOM, y = RANDOM;
- if not contain USED_PIXELS(x,y):
- USED_PIXES(x,y);
- pixel = image.getRGB(x,y);
- red = EXTRACT THE BITWISE(pixel, 16)
- green = EXTRACT THE BITWISE(pixel, 8)
- blue = EXTRACT THE BITWISE(pixel)
- ENCRYPTED_BINARY.append(red)
- ENCRYPTED_BINARY.append(green)
- ENCRYPTED_BINARY.append(blue)
- if ENCRYPTED_BINARY.length equal to or above 8:
- EIGHT_BITS = ENCRYPTED_BINARY.substring(0,8)
- ENCRYPTED_TEXT += EIGHT_BITS
- ENCRYPTED_BINARY.remove(0,8)
- if ENCRYPTED_TEXT.endsWith(END) break;
- if ENCRYPTED_TEXT start with START and ends with END:
- startIndex = INTEGER(START)
- endIndex = INTEGER(END)
- BINARY = textToBinary(ENCRYPTED_TEXT)
- BYTES = binaryToBytes(BINARY)
- PAYLOAD_LENGTH = BYTES.length
- PAYLOAD = [BYTES + PAYLOAD_LENGTH]
- INPUT_STREAM = PAYLOAD
- SALT = input.readBytes()
- ENCRYPTED_DATA = input.readBytes()
- SECRET_KEY = getKeyFromPasswor(pw,salt)
- DECRYPTED_BYTES = byteDecryption(ENCRYPTED_DATA, SECRET_KEY)
- DECOMPRESS_STR = decompressBytes(DECRYPTED_BYTES)
- if DECOMPRESS_STR equals null RETURN "Decoding Failed";
RETURN DECOMPRESS_STR;
function DECODE_PASSKEY (image,privateKey):
- USED_PIXELS = [];
- ENCRYPTED_BINARY = STRING;
- ENCRYPTED_TEXT = STRING;
- SEED = generateSeed(privateKey)
- RANDOM = (SEED);
- START = key_word;
- END = key_word;
- DECOMPRESS_STR = STRING
- while does not contain END:
- x = RANDOM, y = RANDOM;
- if not contain USED_PIXELS(x,y):
- USED_PIXELS(x,y);
- pixel = image.getRGB(x,y);
- red = EXTRACT THE BITWISE(pixel, 16)
- green = EXTRACT THE BITWISE(pixel, 8)
- blue = EXTRACT THE BITWISE(pixel)
- ENCRYPTED_BINARY.append(red)
- ENCRYPTED_BINARY.append(green)
- ENCRYPTED_BINARY.append(blue)
- if ENCRYPTED_BINARY.length equal to or above 8:
- EIGHT_BITS = ENCRYPTED_BINARY.substring(0,8)
- ENCRYPTED_TEXT += EIGHT_BITS
- ENCRYPTED_BINARY.remove(0,8)
- if ENCRYPTED_TEXT.endsWith(END) break;
- if ENCRYPTED_TEXT start with START and ends with END:
- startIndex = INTEGER(START)
- endIndex = INTEGER(END)
- BINARY = textToBinary(ENCRYPTED_TEXT)
- BYTES = binaryToBytes(BINARY)
- PAYLOAD_LENGTH = BYTES.length
- PAYLOAD = [BYTES + PAYLOAD_LENGTH]
- INPUT_STREAM = PAYLOAD
- RSA_KEY = input.readBytes()
- IV = input.readBytes()
- ENCRYPTED_DATA = input.readBytes()
- AES_BYTES = decryptAESKEYFromRSA(RSA_KEY, privateKey)
- SECRET_KEY = getAESFromBytes(AES_BYTES)
- DECRYPTED_BYTES = decryptAES(ENCRYPTED_DATA, SECRET_KEY, IV)
- DECOMPRESS_STR = decompressBytes(DECRYPTED_BYTES)
- if DECOMPRESS_STR equals null RETURN "Decoding Failed";
RETURN DECOMPRESS_STR;