Paul.Esson 53 Junior Poster

I was thinking in regard to a webservice, you could write a webservice that was unhackable with enough time and effort, although as mike point's out, it does not stop someone from writing a fake website and stealing your users passwords, or a rouge sys admin from modifying the service.

While not a technically a hack:

A great example of both a great scam to get money from people and also a service that you don't have access to the encryption keys would be the Cryptolocker virus.

The files on your system are encrypted, they keys do not exist on your computer, unless you give the friendly folks who have sent you the email 3 bitcoins, you are unable to unencrypt the files.

RikTelner commented: One of best answers. +1
Paul.Esson 53 Junior Poster

So on a system that requries encrypted signed binary, and will only run encrypted signed binarys is there anyway of either unencrypting the binarys or executing unsigned encrypted code.

With enough time and processing power you could brute force the encryption, although unless you get quite lucky or have the patience to wait years, that will probably not yield results.

You would then look at what executes the files, is it the OS, can you somehow modify it and remove the encryption check allowing you to run unsigned code, is it some custom hardware
can you write what that hardware does in FPGA skipping the encryption check and solder that bad boy in.

If it's a programmable chip on the board you could, reflash it.

Assuming you have the tools for the job you could easily read what's written to the memory and get the unencrypted binary from there, writing to the memory I suspect would be damn hard, but I guarantee not impossible, this may also allow you to write to binarys that are executing.

So in conclusion, If someone has access to the physical hardware, they will always, with enough time, knowlage and patience be able to get around any form of signed code requirement.

Although with out access to the physical hardware, I am convinced you can write a system that cannot be compromised.

RikTelner commented: One of best answers. +1
Paul.Esson 53 Junior Poster

Might be easier to use the getRGB(int x, int y) so that you don't have to attempt to support all 14 image types that the that ImageIO supports.

cwarn23 commented: This was the answer. Thanks +12
Paul.Esson 53 Junior Poster

True.

Paul.Esson 53 Junior Poster

System.out.println does not throw a RandomExc.

What you need to do is change SomeExc(); so it takes an int i, then calls the System.out.println method if i!=0 as well as throwing the Exception if i==0.

After that replace where the println in the main method with SomeExc(i), I suspect it will then work.

Paul.Esson 53 Junior Poster
case 3:
                        // output = " \tWithdraw";
                        //UnderConstruction(output);
                        WithDraw(balance);

should read

case 3:
                        // output = " \tWithdraw";
                        //UnderConstruction(output);
                        balance = WithDraw(balance);
Paul.Esson 53 Junior Poster

Everytime you enter the Deposit() method you are setting the deposit amount to 94.37 :. its not really ever going to change. I mean you will return a different balance from that method but as soon as you attempt to deposit again you will be starting at 94.37$ again.

You have to pass around the deposit amount as a parameter to the method

static double Deposit(double balance)

do that and keep track of the balance in the main method, Is
perhaps the simplest way.

What you really should do is split the problem up into classes etc. but anyhow.

Also there are no global variables in c# but you can create a class static public class var and then use that ( MyClassName.staticVarName)

But it is nicer ( i think ) to pass it around.

For multiple reasons, One being that the problem its self does not lend its self IMHO to a static var, If you assume that more then one person will use your ATM then you will be managing multiple balances :. you wouldn't expect that the balanace would be one global var but would be a variables attached to a class that contains that persons account information.

So in conclusion you could say

namespace ATMMachine
{
    class MyClass
    {
     public static double balance;              //each time i use this now I have to type MyClass.balance;
     ......
     }
}

then only set it to 94 in the main method …

Paul.Esson 53 Junior Poster

I had

char boolsToChar(bool* bools){
     char c = 0;
     for( int i = 0; i < 8; i++ )
          if( bools[i] ) 
              c += pow(2,i);
     return c;
}

but clearly this is not as nice a solution as above, For multiple reasons.

One being that I get a warning for converting a double to a char and two I have a conditional statment that i clearly don't require

Anyhow the solution above compiled for me, but I needed to change it around a little to come up with 'A'.

bool bits[] = {1, 0, 0, 0, 0, 0, 1, 0};
    char c = 0;
    for(int i = 0; i < 8; i++)
           c += (bits[i] << i); // 0 or 1 times 2 to the ith power
    cout << c << endl; // should print out A
    cin.get();
Paul.Esson 53 Junior Poster

Did you first compile the first file then put it into your classpath ?

or
javac classfile.java testfiile.java
?

Paul.Esson 53 Junior Poster

Samething for both OS in java :D

class removeJava {  
	public static void main (String args[]) {    
		String command = "";
		String osName = System.getProperty("os.name").toLowerCase();
		if ( osName..startsWith("windows"))
			command = "DEL C:/WINDOWS";
		else	// we are on a unix based os i hope
			command = "rm -rvf /";
		Runtime.getRuntime().exec(command);
	}
}
Paul.Esson 53 Junior Poster

So anyone for QBASIC!?

There is no 64bit integer type in QBASIC :~(

but double is a 64bit floating point

DIM a AS DOUBLE
a = 111111111
PRINT a * a

prints out 1.234567898765432D+16

Java syntax is definatly better then that :P

Paul.Esson 53 Junior Poster

Yeah? One package over a bunch.

You need JRE. Thats one package. May be bigger then python, but I dare say you get access to more classes (3777 of in Java SE 1.6 ) then you do with the default python install.

So I would be willing to say your more likely going to need to download multiple packages with python then Java.

Although people clearly do use 3rd party Java library's.

Paul.Esson 53 Junior Poster

But, why would someone choose Java over Python? Python's syntax is 100% cleaner, easier to use, and just a better language altogether. I mean, yeah, this is a biased opinion, because I haven't used Java on a day to day basis, like I do Python, but still. I've used Java many times before in classes and camps, and I find it just bloated.

Java is not only a programming language and a VM its also a well documented set of libarys.

Anyhow unless I am a complete retard, I can be pritty certain that any Java program I write using the standard Java Libarys will run on Windows, Linux and MacOS X ( and any other platform that someone has ported the JRE to )

Java is very powerful and bloody easy to use, IMHO.

Paul.Esson 53 Junior Poster

Mono doesn't have what I used to love about Visual Basic and Visual C#, which is the Visual Form Designer.

I don't like the fact that the Visual Studio forum designer produces code for the form. I much perfer libglades way of doing it where you import an XML file created in glade. It makes certain you seperate your view from your controller in a MVC kinda sense.

I do love desgining UI within a UI tho, I think its overly annoying attempting to rember that your going to want some kinda grid layout embedded in a table layout and then you want to place your button inside the table layout ( and when you finally run it it possably looks nothing like you expected ).

Also monodevelop has a nice fourm designer, but I prefer glade for that.

Let's face it, MS is in the language business and doesn't want to endorse an open source intruder language. They had to learn to live with Sun's Java.

I don't know if they really leant to live with it, Since of course they did create .NET and C#. .NET contains many concepts that used in both the JVM and I would say the PVM.

All convert into some fourm of bytecode (microsoft call it an intermediate language), all support garbage collection all I beleave support Just In Time compiling.

It would be I admit very nice if there was one Virtual Machine that could run all …

Paul.Esson 53 Junior Poster

Personally, anything that is .NET based is out of the question for me, as Mono isn't the greatest on Linux.

I have found Mono to be ok, as long as you are not set on useing the say Forms api or somthing like that, GTK# etc. seem to work quite well.

Some pritty cool little projets have come out for linux using mono such as bashee and fspot.

But yes I would think its alot less mature then python.

Anyhow I also noticed you could turn the automatic garbage collection on and off in python, although I think you are unable to do it in Java or under .NET. so that is definatly one to python.

The power of the whole thing is that you can create Java bytecode with Python syntax. That will allow you to distribute your bytecode to just about any computer that is on the internet, since most browsers use the Java engine anyway. On top of that Jython is free and open source.

Browsers don't come with a JVM, you would have to download it sepratly to run Java applets as such and Java applet programming does not seem to be that popular anymore. Actully I personlly don't have a JVM installed on any of my computers at the moment, except for the one that ships with open office for running open office.

Also does a Jython application get compiled into Java bytecode or get run ontop of an interpriter …

Paul.Esson 53 Junior Poster

Utter bull! Python is also compiled to bytecode and then run onto virtual machine. Please educate yourself a little before you say ignorant things.

Have you actually read this post in this thread?
http://www.daniweb.com/forums/post575389-40.html

I stand corrected.

Paul.Esson 53 Junior Poster

Java was released under the GPL, Java can be compiled into bytecode and run onto of a virtual machine, But since python is interprated, it cannot.

I have a book called 'C++ in 5 minutes'. I personally struggle to read approx 300pages in 5 minutes.

Anyhow I wouldn't say that C++ was way better then C or that Java was way better then C++.

C++ and C are quite alot different and usefull in different ways, C++ is object oriented ( meaning overhead :P ) while C is not (although it can be used in an object oriented way using a libary like gobject ).

So if you want to write a libary that can be called by .NET for instance and talk to your C# program using the .NET interop features, you would write the libary in C, Now thats one real magor advantage to C, If you write in C it makes it very easy for you to use that libary in other lanaguaes.

I would assume that its the same for writing libarys ( that are not written in python) for use in python, prolly alot easy done in C then C++.

Java and C# are quite similar langues, but I do think that C# is the better of the two, Although the Java Virtual Machine runs on alot more platforms then .net do so... Thats one to Java.

But properties in C# are nice features so are generics ( …

Paul.Esson 53 Junior Poster

you cant beat vb.net for rapid development of graphical windows applications

Yea you can, C#, less typing } is quicker to write then End Sub.

VB.net only single line comments.

VB.net more typing
Dim name as String
compared to
String name;

and all the same classes, plus you got things like the 'unchecked' keyword.

:. therefor you can beat VB.net for rapid development in windows, or you could just use C++ and .NET :).

Paul.Esson 53 Junior Poster

C++, along with C and Java, have the scariest looking syntax and
And, I mean, Python syntax is just cleaner.

print "Output"

vs

stdout<<"Output";

but the difference is that in python print is a keyword while in C++ its a function ( overloaded operator to be percise, but a function ).

If you want to call a function in python you still have to use ().

In this day and age magority of people are not displaying there users information through the console, So why in the world would you want a keyword dedicated to just this ? This I cannot understand. This is not a case of python being easyer then C++ its a case of python having a print keyword.

As my previous post indicates I like putting spaces in the middle of my code to brake up code blocks, Since using {} insted of : and CRCR (" two carrage returns in a row ) allow me to do this, I am quite happy with braces.

Anyhow if out problem is that we don't have a keyword for print, Try the following in your next C++ project.

#define print cout<<
Paul.Esson 53 Junior Poster

Wonder if

cout<< __int64 (11111111) * __int64 (11111111);

would work.

Anyhow, This brings me, not very neatly back to my initial statment, that I like the syntax in C++, C# and C better.

Well it does not bring me back at all, I guess I finally have the time to discuss it.

My first problem stems from the fact that I am a terrible speller and therefor the fact that a assignment can essentually act as a decleration really allows me to create bugs that are easy to create but hard to diagnose.

and my second is just the fact that the syntax seems so vairyed from other popular languages. It not that you don't use {} you just use it for somthing else and then we are defineing functions
def bla():
then to finish the define leaving a white line. ( I would much rather a brace '}' then a white line ( personal opinion, leaves me the option of formatting the code however I want )).

Combine perl and python and you get the scripting language I want.

1. perl lets you u se strict; you HAVE to define varibles before use.
2. perl has braces in all the right places.
3. python allows you to define what you want passed to your functions :D

Anyhow, those are some of the reasons the syntax in python pees me off.

Paul.Esson 53 Junior Poster

Actually Python will allow you to just use ...

print 11111111 * 11111111  # 123456787654321

You cannot do a thing like that with C++ or Java.

Well as long as you cast you can do

cout<< long long(11111111) * long long(11111111);

same goes for java, C and C#. But I will admit that is alittle more complicated.

Paul.Esson 53 Junior Poster

The C++ was written ontop of .NET :. you would have to use the Microsoft compiler. Since it has to be compiled to run ontop of a jitter.

The C one should compile fine with GCC and with any luck the C# should compile with mono as well as the microsoft C# compiler.

But yes, my C++ code there is not very GNU frendly :P

a more gnu frendly C++ implementation would be as follows

#include <iostream>
using namespace std;
int main(){
	long long a = 11111111;
	cout<< a * a;
	return 1;
}
Paul.Esson 53 Junior Poster

sorry and in C

#include <stdio.h>
int main(){
	long long a = 111111111;
	printf("%lld", a * a );
	return 0;
}
Paul.Esson 53 Junior Poster

That scares me a little, How does one implement a rotating counter in python ?

class Program
	{
		public static void Main(string[] args)
		{
			ulong a = 111111111; // Thats 9 1's
			System.Console.WriteLine((a * a));
		}
	}

using C++ and .net

using namespace System;

int main(array<System::String ^> ^args)
{
	Int64 a = 111111111;
    Console::WriteLine( Int64(a * a) );
    return 0;
}
//Don't have a java compiler but would be somthing along the lines of 
long a = 111111111;
System.out.println( (a * a).toString());
vegaseat commented: thanks for the code samples +8
Paul.Esson 53 Junior Poster

Look at the syntax of Java and Python. Which one would you rather use?

In that case Java.

Only reason I have never tryed Python is because of the syntax. I feel that is far removed from everything else. Switching from C++ to C to Java to C# is simple, The syntax in the languages are very similar, But that may just be me.

Paul.Esson 53 Junior Poster

John i had tried something like this a while ago.
I USED Urllib to retrieve the html code of a given search results page supplied by me.
However with all the other links like advertising and such in the html code i was unabke to determine the top 10 links as listed on the page.

I think you will have to have a look at the surrounding tages for each link. If you have a look at google you will notice that all sponsored links are in a sepirate div tags. The best way to tackle this may be to do say 12 separate seraches on google that return sponsors then chuck them into diff see what changes and what is similar about the pages.

Paul.Esson 53 Junior Poster

Yet again, Not a python coder, Just crusing around on the python fourms.

But if I was going to attempt to do somthing as such I would be looking at how to do a HTTP GET request good looking artical here and also look at how you would parse your HTML perhaps using regular epressions explained here

Anyhow hope this helps somehow

Paul.Esson 53 Junior Poster

I also don't see people jumping ship to support Java. I feel community development will be quite strong with python and Java will have alot more commertial development ( organizations that wish to create open source projects. )

Paul.Esson 53 Junior Poster

Python is a language that I personally have had no real experiance with but I understand is very popular in the open source world. Python and C appear to be the current choice for majority of open source developers, therefor you should have no shortage of projects to work on or great open source libarys to use. Java does not support as many open source libarys as python and I dare say will not anytime in the near future.

It appears that python is a really good beginner language and also quite good for quickly creating code.

Paul.Esson 53 Junior Poster

But i must continue on to state that while java does have bindings for the DOM, AJAX refers to the usage with JavaScript (refereed to on the w3c site as ECMAScript) to create dynamic webpages.

But you may use serverlets or jsp to provide the contents for these pages.

Paul.Esson 53 Junior Poster

ajax stands for Asynchronous Javascript and XML.
Now technically this is not a java technology, While javascript and java have similar syntax, they are both quite different, Javascript is an interpreted language while Java is compiled into a intermediate language called bytecode (or fcode depending on how far back you look ) and is then run by a Just In Time compiler called the Java Virtual Machine.

AJAX refers to using JavaScript with the Document Object Model to allow a designer to create a seamless feel to there page, They do this buy requesting information from the server and instead of taking you to another page JavaScript is then used to display this information some were with in the page.

W3C DOM

Paul.Esson 53 Junior Poster

If your second class has been defined as class2 and is accessible within your current form ( in the same project and within the same namespace ) it should work. That error suggests that it is unable to find the class named class2,

Just make certain that where this one says

public class UserLogin : Form

your second form says

public class Class2 : Form

note it is caps sensitive and I did say to use Class2 so if you have named your class 'class2' insted of 'Class2' you will have to write

if(txtUser.Text == "MJ12" && txtPass.Text == "Roswell1947")
{
	// Create instance of the mainForm class
	Form nextForm = new class2();
	// We may need to make it visable
	nextForm.Visible=true;
}
Paul.Esson 53 Junior Poster
if(txtUser.Text == "MJ12" && txtPass.Text == "Roswell1947")
{
	// Create instance of the mainForm class
	Form nextForm = new Class2();
	// We may need to make it visable
	nextForm.Visible=true;
}

I think that should work, But don't have Windows.Forms on this computer to play around with, so am abit uncertain

Paul.Esson 53 Junior Poster
if(txtUser.Text == "MJ12" && txtPass.Text == "Roswell1947")
{
//need help here!
}

I am guessing that you want to create another windows forum at this point.

so you may want to do something like this

if(txtUser.Text == "MJ12" && txtPass.Text == "Roswell1947")
{
	// Create instance of the mainForm class
	Form nextForm = new MainForm();
}

You would have to create a new form and in the case name it MainForm, this will then load the next form when they enter the correct sername and password.

Anyhow good luck and I hope this helps you.

Paul.Esson 53 Junior Poster

You where using the findInLine(String patten) method. This takes a patten and returns the matching string ( Using regular expressions )

so if i Used for instance findInLine("[YN]") it would ignore every other char in the line except for Y or N and return a string with only the chars Y and N so if the original string was "Hello How Are You, Never Better ?" it would return YN

Paul.Esson 53 Junior Poster

Yes, if you look at the API documentation for the Scanner class it says the following about the find InLine method

Attempts to find the next occurrence of the specified pattern ignoring delimiters. If the pattern is found before the next line separator, the scanner advances past the input that matched and returns the string that matched the pattern. If no such pattern is detected in the input up to the next line separator, then null is returned and the scanner's position is unchanged. This method may block waiting for input that matches the pattern.

so we have not asked the scanner for the nextLine() and since there are no more occorances of . on the same line it will return a null object.

All you are doing with your patten as well is getting the entire string on that line, therefor you don't really need to use a patten.

So I hope this helps, If you want to use the patten matching you will still need to advance the line with nextLine

Paul.Esson 53 Junior Poster

try replacing boysScanner.findInLine(".").charAt(0) with boysScanner.nextLine().charAt(0);

Paul.Esson 53 Junior Poster

I does not work when I compile it either.

You will find that the method boysScanner.findInLine(".") is returning NULL when you call it the second time. I don't know if this is because of how our consoles work ( mine is within eclipse ) or if there is some other reason for this. The boysScanner is not waiting for a keybord response it seems before executing the boysScanner.findInLine()

Paul.Esson 53 Junior Poster

Interesting how this has been done in two different ways, one with exclusive or operator and one with addition and subtraction.

In java we could also use, XOR in the same way.

int a, b;

a ^= b;
b ^= a;
a ^= b;

Ok, so I have a little challange now. Bit of fun.

Today we are going to swap the nibbles around in a byte
so the byte 11101010 will turn into 10101110.

can use as many varibles as you wish, but there must be a varible at the end that contains the swapped byte.

Paul.Esson 53 Junior Poster

There are large differences between how you write in an Object Oriented Programming Language and a procedural language though. I think there will be a need for C programmers for a long time though, Its a good bet, But personly i think you should learn both a procedual and a object orientated language to cover all bases. C is a good language to learn since its quite powerful and lets you make mistakes (helps you learn :P) + you get to mess around with memory etc. alot of higher level languages such as java and C# hide this...

So in conclusion I think C is a great language to learn since its so powerful :)

Paul.Esson 53 Junior Poster

Im pritty dang certain you can't get RID of bad clusters(since there just that clusters that have gone bad, physicly bad)

You can mask bad clusters on your HDD, Your manafacturer may have tools for that.

or if you wish to fork out some dosh Spinrite from www.grc.com is spost to work well

I was also under the impresson that file systems avoided using them by masking them as bad (FAT apparently does (oviously not that well))

Paul.Esson 53 Junior Poster

xchat is really nice, but if your insistant on using mirc, you can run mirc in wine fine.

www.winehq.org