about | help | code help+videos | done | prefs |
(MEDIUM) Given a String input, create an int array output containing the combined number of four characters at a time in the String. By "combined," I mean that the ASCII character number for each character should be represented in sequence in this rather large number. If the String length is not divisible by four, pad the last int with two extra zeroes at the end for each "missing" character in a four-character sequence. Thus, each output int will have eight digits. Precondition: all the characters in the input String will be capital letters. How does this problem relate to public key cryptography? Encrypting involves raising one number (representing the plaintext) to an exponent, and then finding the remainder after division. Reverse-engineering that process (meaning, a brute-force decryption attack without knowing the private key) would be much easier if the base of the exponentiation function fit within a small, predictable range such as the ASCII character subset. By combining several characters into one number to encrypt, the range of possibilities is massively increased and so is the difficulty of guessing the base of the exponent. And guess what, you will eventually be decrypting and re-assembling these big blocks.HINTThere are math-oriented methods (think: place value) to build these output numbers, or you could use String concatenation. Your choice, but remember that when you are done you do need to return an array of int. apcsaEncryptStringToBlocks("AAAA") → [65656565] apcsaEncryptStringToBlocks("AAA") → [65656500] apcsaEncryptStringToBlocks("B") → [66000000] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 320
Copyright Nick Parlante 2017 - privacy