Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7942407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:57:39+00:00 2026-06-03T23:57:39+00:00

If anyone here knows the meaning of these algorithm, please help me to understand,

  • 0

If anyone here knows the meaning of these algorithm, please help me to understand, because I don’t want to simply copy without knowing how it works.

Here’s the code:

1:

    public static String encryptKey(String key){
    int ch = 0;

    StringBuilder encryptedKey = new StringBuilder();

    for(int i = 0; i < key.length(); i++ ){

        ch = key.charAt(i);

        ch = ~ch;

        encryptedKey.append(ch);
    }

    return encryptedKey.toString();
    }

2:

    public String encrypt(String message, String key){

    StringBuilder encryptedMessage = new StringBuilder();
    char ch;
    int j = 0;

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

        if(j >= key.length()){
            j = 0;
        }

        ch = message.charAt(i);

        ch = (char) (key.charAt(j) ^ ch);

        encryptedMessage.append(ch);

    }

    return encryptedMessage.toString();
    }

Thank’s, once again

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:57:41+00:00Added an answer on June 3, 2026 at 11:57 pm

    These are two simple and standard (and completely insecure, but this is a learning experience) ways to alter data in a reversible way.

    The first one uses ch = ~ch; to toggle all of the bits in the character. So, for example, the letter a, which is ASCII 97 or binary 01100001, would become 10011110. This is reversible because you can apply exactly the same operation to the encrypted data to retrieve the original message.

    The second is slightly more secure and uses the ^ (exclulsive-or) operator to alter the bits in each character based on a key: each bit in the message character is compared to the corresponding bit in the key character. If the bits are the same (either both 0 or both 1), the encrypted bit is 0. If the bits are different, the encrypted bit is 1. This is reversible because you can apply the same ^ operation again, using the same key, to retrieve the original message.

    As a side note, all modern ciphers (such as DES3 and AES) are based on the exclusive-or operation, combined with an algorithm that “mixes” the bits in a specified way, so it’s much harder to guess the key. The ciphertext can be decrypted by running the algorithm in reverse, or by taking computational short cuts that are mathematically equivalent.

    Warning, and rant: This is clearly homework, and you’ve already admitted that both you and your friend are cheating by copying someone else’s answer. As bad as that may be, it’s even worse if you can’t explain it, especially because I promise you that every other student who has ever taken the course and copied the answer will have produced these same 2 solutions. What’s stupidly worse is that encryption is dead simple: it all comes down to flipping bits.

    So here’s the essence of cryptography:

    • Take each character in the message.
    • Modify the character somehow, according to some rule you invent. The important thing is that you must be able to reverse this rule, so for example, always setting the 3rd bit to 1 and the 6th bit to 0 won’t work, because you’ll no longer know what they originally were. But swapping the 3rd and 6th bits would be fine; you’d just swap them again to decrypt.
    • Append the modified character to your output as the encrypted text.
    • Repeat until you run out of characters.

    To decrypt, follow the same algorithm, but reverse whatever rule you used to modify each character.

    Uibu’t bmm uifsf jt up ju. Hppe mvdl!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If anyone knows the name for these types of comments, if one exists, please
I was wondering if anyone here knows how to find the complete path (from
I know I can get answers here but I was wondering if anyone knows
I wanted to know if anyone here knows how to import a 3D Object
does anyone here knows if there exists a JMS server that could be executed
Just wanna ask anyone here knows why when i put a placeholder in my
I was wondering if anyone here knows an efficient way to cast an integer
is there anyone here who knows how to create a panel tab?it wasn't discussed
Does anyone here knows why and how the i-nigma app can be integrated into
does anyone here knows the correct way of associating a single entity(a pojo class)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.