Security features
-
I was tasked in my schooling with adding security features to a calculator code we wrote for a previous project. I have never used security features before and have not the first idea how to incorporate them in my project. We apparently have to add them to our functions (plus, minus, multiply, divide). I'm not asking for anyone to do the work for me but I could use help with what exactly needs to be done. The following is an example of the code for the button that divides:
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles divNum.Click
ansBox.Text = (Integer.Parse(numBox1.Text) / Integer.Parse(numBox2.Text)).ToString()
End SubIf more of the program is needed or anything just let me know. Any help would be amazing!
-
I was tasked in my schooling with adding security features to a calculator code we wrote for a previous project. I have never used security features before and have not the first idea how to incorporate them in my project. We apparently have to add them to our functions (plus, minus, multiply, divide). I'm not asking for anyone to do the work for me but I could use help with what exactly needs to be done. The following is an example of the code for the button that divides:
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles divNum.Click
ansBox.Text = (Integer.Parse(numBox1.Text) / Integer.Parse(numBox2.Text)).ToString()
End SubIf more of the program is needed or anything just let me know. Any help would be amazing!
What do you mean by "security features"?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
What do you mean by "security features"?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Here is my teachers exact wording of the assignment. The GUI interface for your calculator now needs additional functions. To add security functions address the following in your Visual Studio file: Program at least one of the functions (add, subtract, multiple or divide) in your calculator program to include a security feature. An example of a security feature is to declare a variable as "private" as opposed to "public" (conduct some independent research if necessary to refresh on these topics).
-
What do you mean by "security features"?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I guess it's anything I can add to my code to make it more secure
-
Here is my teachers exact wording of the assignment. The GUI interface for your calculator now needs additional functions. To add security functions address the following in your Visual Studio file: Program at least one of the functions (add, subtract, multiple or divide) in your calculator program to include a security feature. An example of a security feature is to declare a variable as "private" as opposed to "public" (conduct some independent research if necessary to refresh on these topics).
Other than being in VB instead of c# I don't see anything to change in the code you've shown. ;) Seriously: From the wording, it looks like the issue is the accessibility of the various variables and methods in the implementation of your program. Make sure everything has the most restrictive accessibility (
public/internal/protected/private
) that still allows it to function correctly. Then look at things that aren'tprivate
and think about how you could redesign your code to reduce their "exposure". I'd suggest you avoid modifying the accessibility of any code generated by the designer, lest you confuse the designer. -
Here is my teachers exact wording of the assignment. The GUI interface for your calculator now needs additional functions. To add security functions address the following in your Visual Studio file: Program at least one of the functions (add, subtract, multiple or divide) in your calculator program to include a security feature. An example of a security feature is to declare a variable as "private" as opposed to "public" (conduct some independent research if necessary to refresh on these topics).
-
As Matt says, this has nothing to do with security; it's a pity your teacher does not understand that.
Use the best guess
He left this piece of python code as an example for the assignment but idk where in the code it has the security feature. From everything I have found all of my code says private on it so if that's what he wants it should have been already done lol #!/usr/bin/python # from Tkinter import * # Download this from http://www.manning.com/grayson/ from tkMessageBox import * # Download this from http://www.manning.com/grayson/ # Calculator is a class derived from Frame. Frames, being someone generic, # make a nice base class for whatever you what to create. class Calculator(Frame): # Create and return a packed frame. def frame(this, side): w = Frame(this) w.pack(side=side, expand=YES, fill=BOTH) return w # Create and return a button. def button(this, root, side, text, command=None): w = Button(root, text=text, command=command) w.pack(side=side, expand=YES, fill=BOTH) return w # Enter a digit. need_clr = False def digit(self, digit): if self.need_clr: self.display.set('') self.need_clr = False self.display.set(self.display.get() + digit) # Change sign. def sign(self): need_clr = False cont = self.display.get() if len(cont) > 0 and cont[0] == '-': self.display.set(cont[1:]) else: self.display.set('-' + cont) # Decimal def decimal(self): self.need_clr = False cont = self.display.get() lastsp = cont.rfind(' ') if lastsp == -1: lastsp = 0 if cont.find('.',lastsp) == -1: self.display.set(cont + '.') # Push a function button. def oper(self, op): self.display.set(self.display.get() + ' ' + op + ' ') self.need_clr = False # Calculate the expressoin and set the result. def calc(self): try: self.display.set(`eval(self.display.get())`) self.need_clr = True except: showerror('Operation Error', 'Illegal Operation') self.display.set('') self.need_clr = False def __init__(self): Frame.__init__(self) self.option_add('*Font', 'Verdana 12 bold') self.pack(expand=YES, fill=BOTH) self.master.title('Simple Calculator') # The StringVar() object holds the value of the Entry. self.display = StringVar() e = Entry(self, relief=SUNKEN, textvaria
-
Here is my teachers exact wording of the assignment. The GUI interface for your calculator now needs additional functions. To add security functions address the following in your Visual Studio file: Program at least one of the functions (add, subtract, multiple or divide) in your calculator program to include a security feature. An example of a security feature is to declare a variable as "private" as opposed to "public" (conduct some independent research if necessary to refresh on these topics).
This is a visual basic calculator code he also gave as an example: Public Class Form1 Private Sub calculateBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateBtn.Click Dim number1 As Double Dim number2 As Double Dim answer As Double If input1TextBox.Text = "" OrElse input2TextBox.Text = "" Then MessageBox.Show("Please Enter a Number") ElseIf additionRb.Checked = False And subtractRb.Checked = False And multiplyRb.Checked = False And divideRb.Checked = False Then MessageBox.Show("Please Choose an Operation") Else number1 = Double.Parse(input1TextBox.Text) number2 = Double.Parse(input2TextBox.Text) If additionRb.Checked = True Then answer = number1 + number2 answerLbl.Text = answer.ToString() ElseIf subtractRb.Checked = True Then answer = number1 - number2 answerLbl.Text = answer.ToString() ElseIf multiplyRb.Checked = True Then If number1 = 0 OrElse number2 = 0 Then answerLbl.Text = "0" Else answer = number1 * number2 answerLbl.Text = answer.ToString() End If ElseIf divideRb.Checked = True Then If number1 = 0 Then answerLbl.Text = "0" ElseIf number2 = 0 Then answerLbl.Text = "Cannot Divide by Zero" Else answer = number1 / number2 answerLbl.Text = answer.ToString() End If End If End If End Sub End Class
-
He left this piece of python code as an example for the assignment but idk where in the code it has the security feature. From everything I have found all of my code says private on it so if that's what he wants it should have been already done lol #!/usr/bin/python # from Tkinter import * # Download this from http://www.manning.com/grayson/ from tkMessageBox import * # Download this from http://www.manning.com/grayson/ # Calculator is a class derived from Frame. Frames, being someone generic, # make a nice base class for whatever you what to create. class Calculator(Frame): # Create and return a packed frame. def frame(this, side): w = Frame(this) w.pack(side=side, expand=YES, fill=BOTH) return w # Create and return a button. def button(this, root, side, text, command=None): w = Button(root, text=text, command=command) w.pack(side=side, expand=YES, fill=BOTH) return w # Enter a digit. need_clr = False def digit(self, digit): if self.need_clr: self.display.set('') self.need_clr = False self.display.set(self.display.get() + digit) # Change sign. def sign(self): need_clr = False cont = self.display.get() if len(cont) > 0 and cont[0] == '-': self.display.set(cont[1:]) else: self.display.set('-' + cont) # Decimal def decimal(self): self.need_clr = False cont = self.display.get() lastsp = cont.rfind(' ') if lastsp == -1: lastsp = 0 if cont.find('.',lastsp) == -1: self.display.set(cont + '.') # Push a function button. def oper(self, op): self.display.set(self.display.get() + ' ' + op + ' ') self.need_clr = False # Calculate the expressoin and set the result. def calc(self): try: self.display.set(`eval(self.display.get())`) self.need_clr = True except: showerror('Operation Error', 'Illegal Operation') self.display.set('') self.need_clr = False def __init__(self): Frame.__init__(self) self.option_add('*Font', 'Verdana 12 bold') self.pack(expand=YES, fill=BOTH) self.master.title('Simple Calculator') # The StringVar() object holds the value of the Entry. self.display = StringVar() e = Entry(self, relief=SUNKEN, textvaria
Well I know nothing about python; and you posted this question in the Visual Studio forum. However, and more relevant, there is nothing you can do to a calculator to make it secure, even if we really understood what that is supposed to mean. Go back and talk to your teacher and get a better explanation of what problem you are supposed to be addressing.
Use the best guess
-
Well I know nothing about python; and you posted this question in the Visual Studio forum. However, and more relevant, there is nothing you can do to a calculator to make it secure, even if we really understood what that is supposed to mean. Go back and talk to your teacher and get a better explanation of what problem you are supposed to be addressing.
Use the best guess
I will. Thanks anyway!