Presentation is loading. Please wait.

Presentation is loading. Please wait.

DEVRY COMP 122 L AB 7 L AB R EPORT AND S OURCE C ODE C HECK THIS A+ TUTORIAL GUIDELINE AT HTTP :// WWW. ASSIGNMENTCLOUD. COM / COMP -122/ COMP LAB.

Similar presentations


Presentation on theme: "DEVRY COMP 122 L AB 7 L AB R EPORT AND S OURCE C ODE C HECK THIS A+ TUTORIAL GUIDELINE AT HTTP :// WWW. ASSIGNMENTCLOUD. COM / COMP -122/ COMP LAB."— Presentation transcript:

1 DEVRY COMP 122 L AB 7 L AB R EPORT AND S OURCE C ODE C HECK THIS A+ TUTORIAL GUIDELINE AT HTTP :// WWW. ASSIGNMENTCLOUD. COM / COMP -122/ COMP -122- LAB -7- LAB - REPORT - AND - SOURCE - CODE F OR MORE CLASSES VISIT HTTP :// WWW. ASSIGNMENTCLOUD. COM COMP 122 W EEK 7 I L AB T HE FOCUS OF THIS LAB IS ON USING STRINGS. Y OU WILL HAVE AN OPPORTUNITY TO WORK WITH BOTH C STYLE STRINGS AND THE STRING DATA TYPE. T HIS LAB ALSO GIVES YOU AN OPPORTUNITY TO USE WHAT YOU HAVE LEARNED PREVIOUSLY, INCLUDING USING FUNCTIONS, ARRAY PROCESSING, REPETITION, AND SELECTION. Y OU WILL ALSO HAVE AN OPPORTUNITY TO WORK WITH FILE INPUT AND OUTPUT. Y OU ARE TO DESIGN AND IMPLEMENT A PROGRAM WHICH DOES ENCRYPTION AND DECRYPTION OF DATA FROM FILES. E NCRYPTION IS THE PROCESS OF TAKING PLAIN LINES OF TEXT AND PERFORMING SOME ALGORITHMIC TRANSFORMATION ON THE DATA TO CREATE AN ENCRYPTED LINE OF TEXT WHICH LOOKS NOTHING LIKE THE ORIGINAL. D ECRYPTION IS THE PROCESS OF TAKING AN ENCRYPTED LINE OF TEXT AND PERFORMING SOME ALGORITHMIC TRANSFORMATION ON THE DATA TO RECOVER THE ORIGINAL LINE OF PLAIN TEXT. E NCRYPTION AND D ECRYPTION A PPROACH HTTP :// WWW. ASSIGNMENTCLOUD. COM / COMP -122/ COMP -122- LAB -7- LAB - REPORT - AND - SOURCE - CODE HTTP :// WWW. ASSIGNMENTCLOUD. COM

2 O UR APPROACH TO ENCRYPTION AND DECRYPTION INVOLVES TWO STRINGS. T HE FIRST IS AN ENCRYPTION / DECRYPTION STRING WHICH WE WILL ALLOW TO BE UP TO 128 LOWER CASE ALPHABETICAL CHARACTERS IN LENGTH. T HE SECOND STRING IS A LINE OF TEXT FROM A FILE THAT IS TO BE ENCRYPTED OR DECRYPTED. O UR BASIC STRATEGY FOR ENCRYPTING DATA IS BASED ON MAPPING ALPHABETICAL CHARACTERS TO SPECIFIC VALUES, THEN DOING SOME SIMPLE MATHEMATICAL OPERATIONS TO CREATE A NEW VALUE. F IRST OF ALL, EVERY CHARACTER IN EITHER THE ENCRYPTION STRING OR THE INPUT STRING IS MAPPED TO A NUMBER BETWEEN 0 AND 25 BASED ON ITS POSITION IN THE ALPHABET. = 0 = 1 = 25 T HE MAPPED VALUE OF A CHARACTER IS EASILY OBTAINED BY DOING THE FOLLOWING : F OR LOWER CASE CHARACTERS, SUBTRACT ' A ' FROM THE CHARACTER. F OR UPPER CASE CHARACTERS, SUBTRACT 'A' FROM THE CHARACTER. T O CALCULATE THE MODIFIED VALUE OF THE FIRST CHARACTER OF INPUT WE ADD ITS MAPPED VALUE TO THE MAPPED VALUE FROM THE FIRST CHARACTER OF THE ENCRYPTION STRING. T HIS MODIFIED VALUE IS THEN ADJUSTED USING % 26 TO MAKE SURE THAT THE FINAL MODIFIED VALUE IS WITHIN THE 0 - 25 RANGE. T O CREATE THE FINAL ENCRYPTED CHARACTER VALUE FOR THE FIRST CHARACTER, SIMPLY DO THE FOLLOWING : F OR LOWER CASE CHARACTERS, ADD ' A ' TO THE MODIFIED VALUE. F OR UPPER CASE CHARACTERS, ADD 'A' TO THE MODIFIED VALUE. T HIS IS DONE FOR EACH ALPHABETIC CHARACTER IN THE INPUT STRING. N ON - ALPHABETIC CHARACTERS SIMPLY MAINTAIN THEIR PRESENT VALUE. I F THE INPUT STRING IS LONGER THAN THE ENCRYPTION STRING, SIMPLY REUSE MAPPED VALUES FROM THE ENCRYPTION STRING. F OR INSTANCE, IF THE ENCRYPTION STRING HAS 10 CHARACTERS ( INDEX VALUES 0 - 9), WHEN PROCESSING THE 11 TH INPUT CHARACTER ( INDEX 10), SIMPLY USE THE INPUT CHARACTER INDEX % LENGTH OF ENCRYPTION STRING ( IN THIS CASE 10 % 10 IS 0) TO SELECT THE VALUE FROM THE ENCRYPTION STRING TO USE FOR MAPPING.

3 T HE DECRYPTION PROCESS IS BASICALLY THE SAME AS THE ENCRYPTION PROCESS. T HE ONLY DIFFERENCE IS THE VALUE OF THE MAPPED CHARACTER FROM THE ENCRYPTION STRING. F OR LOWER CASE ENCRYPTION, THE MAPPED FROM ENCRYPTION STRING - ' A ' F OR UPPER CASE ENCRYPTION, THE MAPPED FROM ENCRYPTION STRING - 'A' F OR LOWER CASE DECRYPTION, THE MAPPED - ( CHARACTER FROM ENCRYPTION STRING - ' A ') F OR UPPER CASE DECRYPTION, THE MAPPED - ( CHARACTER FROM ENCRYPTION STRING - 'A') P ROGRAM R EQUIREMENTS Y OUR PROGRAM MUST MEET THE FOLLOWING REQUIREMENTS : 1. Y OU MUST ASK THE USER IF THEY WANT TO PERFORM AN ENCRYPTION OR DECRYPTION OPERATION. 2. Y OU MUST ASK THE USER TO ENTER THE NAME OF THE FILE THEY WANT TO ENCRYPT OR DECRYPT. 3. Y OU MUST GET AN ENCRYPTION KEY FROM THE USER WHICH CAN BE UP TO 128 CHARACTERS. T HE KEY MUST BE ALL LOWER CASE ALPHABETIC CHARACTERS. 4. Y OU MUST HAVE A FUNCTION WHICH TAKES THE ENCRYPTION KEY AND CREATES AN ENCRYPTION MAP FROM IT. F OR EACH CHARACTER IN THE ENCRYPTION KEY STRING, SUBTRACT THE LOWER CASE LETTER ' A ' AND STORE THE RESULT IN THE CORRESPONDING ENCRYPTION MAP ARRAY. 5. Y OU MUST HAVE A FUNCTION WHICH TAKES THE ENCRYPTION KEY AND CREATES A DECRYPTION MAP FROM IT. F OR EACH CHARACTER IN THE ENCRYPTION KEY STRING, SUBTRACT THE LOWER CASE LETTER ' A ' FROM IT. T HEN SUBTRACT THAT RESULT FROM 26 AND STORE THE VALUE IN THE CORRESPONDING DECRYPTION MAP ARRAY. 6. Y OU MUST HAVE A FUNCTION WHICH WILL DO THE ENCRYPTION OR DECRYPTION TRANSFORMATION. T HIS FUNCTION TAKES THE FOLLOWING PARAMETERS : A CONSTANT C STRING CONTAINING THE LINE OF TEXT TO BE TRANSFORMED. A CONSTANT C CHARACTER ARRAY WHICH CONTAINS THE ENCRYPTION OR DECRYPTION MAP. A N INTEGER WHICH CONTAINS THE LENGTH OF THE ENCRYPTION MAP. A STRING REFERENCE ( OUTPUT ) WHICH WILL CONTAIN THE ENCRYPTED OR DECRYPTED STRING UPON COMPLETION. T HE CORE OF THE ENCRYPTION / DECRYPTION ALGORITHM IS


Download ppt "DEVRY COMP 122 L AB 7 L AB R EPORT AND S OURCE C ODE C HECK THIS A+ TUTORIAL GUIDELINE AT HTTP :// WWW. ASSIGNMENTCLOUD. COM / COMP -122/ COMP LAB."

Similar presentations


Ads by Google