1 answer

Explaination on how the decryption of the vignere cipher works.        String d_result = "";...

Question:

Explaination on how the decryption of the vignere cipher works.

       String d_result = "";

       str = str.toUpperCase();

       for(int i = 0, j = 0; i < str.length(); i++)

       {

           char c = str.charAt(i);

           if(c < 'A' || c >'Z')

               continue;

           result += (char)((c - k.charAt(j)+ 26)% 26 + 'A');

           j = ++j % k.length();

       }

       return d_result;

   }


Answers


       String d_result = "";

       str = str.toUpperCase();//String value is converted into upper case
//here loop converts takes encrypted text and converts it into original text using key value.

       for(int i = 0, j = 0; i < str.length(); i++)
//The below defined for loop process each and every character in the encrypted text
//until the entire string is converted to its original form.
       {
//These lines takes each character of the encrypted text at a time and check if it lies between the ascii
//range of character 'A' and 'Z'. Characters are only processed if the character lies in the range,
//else we move on to process next character of the encrypted text.
           char c = str.charAt(i);

           if(c < 'A' || c >'Z')

               continue;
//The encrypted character is converted to the original character using the formula that uses the key value.
// The next character of the key value is obtained by using modulus operator that repeats the characters of
//the key so that its total length is equal to that of the original text.

           result += (char)((c - k.charAt(j)+ 26)% 26 + 'A');

           j = ++j % k.length();

       }
//returns the plain text.
       return d_result;

   }

.

Similar Solved Questions

1 answer
Question 6 The equivalent capacitance of three capacitors in parallel is: OA. 1 Tea B. 1...
Question 6 The equivalent capacitance of three capacitors in parallel is: OA. 1 Tea B. 1 1 른 -= C, + C₂ + C₃ Сед c. Cea + at C2 C3 D. Ceq = C1+C2 + C3 E. Always equivalent to any one of the capacitors....
1 answer
Drug A has an half-life of 12 hours and a volume of distribution of 80 L....
Drug A has an half-life of 12 hours and a volume of distribution of 80 L. How many mg of drug are in the body when the plasma concentration is 0.4 ug/mL?...
1 answer
Assignment 4 Part I. Index of Intra-Industry Trade (IIT) for Country In class, we learned how...
Assignment 4 Part I. Index of Intra-Industry Trade (IIT) for Country In class, we learned how to calculate the IIT index for each industry. How can it measure for a country as a whole? In Appleyard book (p.202), If we designate commodity categories by i, represent exports and imports in each categor...
1 answer
Why is it important to recognize your personal proficiency limitations during the process of e-discovery? What...
Why is it important to recognize your personal proficiency limitations during the process of e-discovery? What could be one consequence of failing to realize you lack the skill necessary to handle the type of discovery action presented?...
1 answer
9.6 A CMOS cascode amplifier shown below has identical CS and CG transistors that have W/L-5.4...
9.6 A CMOS cascode amplifier shown below has identical CS and CG transistors that have W/L-5.4 μm/0.36 μm and biased at 1-0.2 mA. The fabrication process has k'n -400 μΑ/V2, and VA-5 V/um. At what value of R, does the voltage gain Vo/Vi become -100 V/V? Rin2...
1 answer
Briefly discuss the critical success factors for TQM implementation and their impact on performance of small...
Briefly discuss the critical success factors for TQM implementation and their impact on performance of small and medium enterprises (SMEs). Please choose an SME to demonstrate the impact of Strategic TQM on both the operational and organizational performance of your chosen organization....
1 answer
3. Which indicator has a fast and slow version where the slow version is a doubly...
3. Which indicator has a fast and slow version where the slow version is a doubly smoothed moving average? a. moving average convergence divergence b. stochastic oscillator c. simple moving average d. McClellan Summation Index e. none of the above...
2 answers
Bob bought an 18-pack of gum. He gave 4 pieces to Erica and 5 pieces to his mother. His brother then gave him a pack with 10 pieces in it. How many pieces of gum does Bob have now?
Bob bought an 18-pack of gum. He gave 4 pieces to Erica and 5 pieces to his mother. His brother then gave him a pack with 10 pieces in it. How many pieces of gum does Bob have now?...
1 answer
FINANCIAL LEVERAGE EFFECTS Firms HL and LL are identical except for their financial leverage ratios and...
FINANCIAL LEVERAGE EFFECTS Firms HL and LL are identical except for their financial leverage ratios and the interest rates they pay on debt. Each has $25 million in invested capital, has $6.25 million of EBIT, and is in the 40% federal-plus-state tax bracket. Firm HL, however, has a debt-to-capital ...
1 answer
Please answer b and d and give a solution with a written explanation to each step...
Please answer b and d and give a solution with a written explanation to each step 10. (10) Indicate whether or not each ionic reaction will occur by writing "Yes" or "No Reaction after the reaction arrow. Al2(SO4 3 NaOH yes nty KBr Na3PO4 AgNO3 Nal Yes CaBr2 Na3PO4...
1 answer
And ions c) Lewis Structures and formal charge-way to symbolize covalent molecules Four basic steps to...
and ions c) Lewis Structures and formal charge-way to symbolize covalent molecules Four basic steps to draw leis structure i) Determine the connectivity on the atoms in the molecule ii) Determine total number of valence electrons ili) Add the valence electrons to the molecule iv) Attemp t to fill ea...
1 answer
A cylinder, with a piston pressing down with a constant pressure, is filled with 2.20 moles...
A cylinder, with a piston pressing down with a constant pressure, is filled with 2.20 moles of a gas (n1), and its volume is 43.0 L (V1). If 0.700 mole of gas leak out, and the pressure and temperature remain the same, what is the final volume of the gas inside the cylinder?...
1 answer
Without doing any calculations, match the following thermodynamic properties with their appropriate numerical sign for the...
Without doing any calculations, match the following thermodynamic properties with their appropriate numerical sign for the following exothermic reaction 4NH3(g)502(g)4NO(g) + 6H20(g) Clear All 0 AHxn <0 ASrxn AGrxn >0 low T,< 0 high T ASuniverse <0 low T, 0 high T Next Previous...
1 answer
You have collected the following data on internal pressure strength of 16 glass bottles. (a) Does...
You have collected the following data on internal pressure strength of 16 glass bottles. (a) Does it seem reasonable to conclude that the internal pressure strength is normally distributed? 226.16208.15 211.14 221.31 02 ,201 .6 2M 219.54193.71 188.12 202.21 193.73 200.81 224.39 201.63 195.45 203...
1 answer
Question 3 O ou 15 ml of 0.01 M HCl was used to titrate 30 ml...
Question 3 O ou 15 ml of 0.01 M HCl was used to titrate 30 ml of Ca(OH)2. Calculate the Ksp of Ca(OH)2....
1 answer
Suppose Microsoft has 8.75 billion shares outstanding and pays a marginal corporate tax rate of 21%....
Suppose Microsoft has 8.75 billion shares outstanding and pays a marginal corporate tax rate of 21%. If Microsoft announces that it will payout $50 billion in cash to investors through a combination of a special dividend and a share repurchase, and if investors had previously assumed Microsoft would...
1 answer
Plz help general chem
in a coffee cup calorimeter, 50.0ml of 1.00M NaOH and 50.00ml of1.00M HCI are mixed. Both solutions were originally at24.6.C.After the reaction, the final temperatre is 31.3.C. Given that the density of NaCI solution is 1.038 g/ml andthespecific heat of NaCI solution is 3.87 J/g. C, calculatethe &De...