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

  • SEARCH
  • Home
  • 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 8714717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:39:54+00:00 2026-06-13T05:39:54+00:00

I got confused in an assignment :D given a UML diagram I had to

  • 0

I got confused in an assignment 😀
given a UML diagram I had to Implement a course management application, one part is the Student class as follow

    public class Student extends Person implements Encryptable {
    private String program;
    private Vector<Course> courses;

//constructor. 
    public Student(String Name, String pnr, String tel, String prog) {
            super(Name, pnr, tel);
            program = prog;
            courses = new Vector<Course>();
        }
/* implementation of related methods 
  ......  */

        @Override
    public void encrypt(String password) {
    }

    @Override
    public void decrypt(String password) {  
    }

all other classes and all related setters and getters of this class are implemented also the Encryptable interface is as follow

public interface Encryptable {

    public void encrypt(String password);
    public void decrypt(String password);
}

in an earlier task I had implemented a class “PassworCrypter” that I should use that class

public class PasswordCrypter {
    Cipher ecipher;
    Cipher dcipher;
    SecretKey key;
    DESKeySpec dks;
    SecretKeyFactory skf;
    byte[] psword;

    public PasswordCrypter(String password) {

        try {
            psword = password.getBytes("UTF-16");
            dks = new DESKeySpec(psword);
            skf = SecretKeyFactory.getInstance("DES");
            key = skf.generateSecret(dks);
            ecipher = Cipher.getInstance("DES");
            ecipher.init(Cipher.ENCRYPT_MODE, key);
            dcipher = Cipher.getInstance("DES");
            dcipher.init(Cipher.DECRYPT_MODE, key);
        } catch (NoSuchAlgorithmException e) {
            throw new CrypterException(e);
        } catch (NoSuchPaddingException e) {
            throw new CrypterException(e);
        } catch (InvalidKeyException e) {
            throw new CrypterException(e);
        } catch (InvalidKeySpecException e) {
            throw new CrypterException(e);
        } catch (UnsupportedEncodingException e) {
            throw new CrypterException(e);
        }

    }

    public byte[] encrypt(byte[] array) {

        try {
            return ecipher.doFinal(array);
        } catch (IllegalBlockSizeException e) {
            throw new CrypterException(e);
        } catch (BadPaddingException e) {
            throw new CrypterException(e);
        }
    }

    public byte[] decrypt(byte[] array) {

        try {
            return dcipher.doFinal(array);
        } catch (IllegalBlockSizeException e) {
            throw new CrypterException(e);
        } catch (BadPaddingException e) {
            throw new CrypterException(e);
        }
    }
}

I should use PasswordCrypter class on local and inherited fields of the Student
class. When a Student object is encrypted it should not be possible to get data
such as a student’s name without first calling decrypt. A Student object should
always be encrypted except for when you need to access any of its data.
can any one give me idea or tell me how should I encrypt this damn student 🙂

  • 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-13T05:39:56+00:00Added an answer on June 13, 2026 at 5:39 am

    I think you have problem in Encryptable. The signature of the method should be

    public void encrypt(Encrypter enc);
    public void decrypt(Decrypter dec);
    

    Where you can define two separate interfaces Encrypter and Decrypter. so finally you can use PasswordCrypter as central class which implements these two methods.

     public class PasswordCrypter implements Encrypter,Decrypter  {
    

    So now inside your Student class you can do

    public void encrypt(Encrypter enc) {
       byte[] programbytes = enc.encrypt(program);
    }
    
    public void encrypt(Decrypter dec) {
       program = dec.decrypt(programbytes);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got confused with this two lines of coding : this.class.methods.name This is called
I've got confused at the moment. I've got one database to developed for MLM
I was reading Google C++ Style Guide, and got confused in the Exceptions part.
After reading several articles on jms connection pooling I got confused. Could one please
today I got an assignment from my school and I am bit confused about
There are a few concepts about iPhone memory management that have got me confused,
I've just got confused how to implement something in a generic way in C++.
First time using jQuery parent and got confused, here's my html: <div id=friends_inveni class=friends_rec
I'm playing around with the HttpWebRequest class and got confused about the Timeout/ReadWriteTimeout members.
I was doing an assignment and had an update class which accepted the SQL

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.