Jump to content




Help with some vb.net and java code- Help still needed


  • You cannot reply to this topic
8 replies to this topic

#1 RoD

  • Members
  • 313 posts

Posted 31 March 2014 - 09:38 PM

Hi everyone! :D

I am trying to make a encryption/decryption program for windows.
Some code is done and because i am new to vb.net i took this function from a website:
Spoiler

The function works great and the program is just like i want.
Now heres my problem:
My friend uses a tablet (android) and i want to make this app to android as well (not for selling or to be at the store, just for our group of friends and my family).
I already have eclipse with the android SDK and everything needed (i did a test program with a simple tring displayed on the tablet), but i cant do this app becasue i am really noob at java. :P

Can anyone do the code above work for java, or if someone can help me doing this app?

I know that i may be wanting too much without learning and experimenting first but it would be really apreciated :)

Edited by RoD, 03 April 2014 - 05:25 PM.


#2 zekesonxx

  • Signature Abuser
  • 263 posts
  • LocationWhere you aren't

Posted 31 March 2014 - 11:39 PM

This is actually just a really confusing implementation of ROT. Here's a direct JS port:
Spoiler

And here's a rewritten JS version that isn't stupid: https://gist.github....kesonxx/9904781

#3 6677

  • Members
  • 197 posts
  • LocationCambridgeshire, England

Posted 01 April 2014 - 08:14 AM

View Postzekesonxx, on 31 March 2014 - 11:39 PM, said:

This is actually just a really confusing implementation of ROT. Here's a direct JS port:
Firstly he was after Java not javascript (the 2 contrary to name are not related).

And that is most certainly not ROT. Rot would shift all characters in a given string by n places, typically used with 13 on upper case only text. This shifts each character by the value of the corresponding character in the key with a modulo for where the values overflow. Closest I can think of from the top of my head that also does this is Solitaire but that also has some complexities of its own.
Problem with this is that if 2 messages are sent using the same key it does become a rather trivial operation to reverse engineer the key and from that the messages.

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 01 April 2014 - 12:02 PM

Here's a stab at it; I've not tested it, as I've not played with Java for a little while and am curious as to whether I can still get something this simple right without the help of a compiler. ;)

Spoiler

There may be some "loss of precision" errors lurking in there, but they should be easy to sort out if so.

#5 RoD

  • Members
  • 313 posts

Posted 01 April 2014 - 05:23 PM

View PostBomb Bloke, on 01 April 2014 - 12:02 PM, said:

Here's a stab at it; I've not tested it, as I've not played with Java for a little while and am curious as to whether I can still get something this simple right without the help of a compiler. ;)

Spoiler

There may be some "loss of precision" errors lurking in there, but they should be easy to sort out if so.
Java is case sensitive right? Your code had string instead of String :P (or is just me being stupid? XD)

Edited by RoD, 01 April 2014 - 05:24 PM.


#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 01 April 2014 - 09:36 PM

Indeed, that'd need to be switched to an upper-case S.

#7 RoD

  • Members
  • 313 posts

Posted 01 April 2014 - 09:47 PM

View PostBomb Bloke, on 01 April 2014 - 09:36 PM, said:

Indeed, that'd need to be switched to an upper-case S.
Its already done :) but no more errors in your code, good job with no compiler :D
The code is working fine and just like i expected, thanks. Now i will see if zekesonxx can help me further with the android part.
Or if someone can:
I can't get a input to be stored in a variable O.o one of the most simple things and i can't...
Spoiler
I put the toast to test the string but so far i only go a blank toast... Any ideas of what's the matter?

Edited by RoD, 01 April 2014 - 09:48 PM.


#8 zekesonxx

  • Signature Abuser
  • 263 posts
  • LocationWhere you aren't

Posted 02 April 2014 - 01:08 AM

View Post6677, on 01 April 2014 - 08:14 AM, said:

View Postzekesonxx, on 31 March 2014 - 11:39 PM, said:

This is actually just a really confusing implementation of ROT. Here's a direct JS port:
Firstly he was after Java not javascript (the 2 contrary to name are not related).

And that is most certainly not ROT. Rot would shift all characters in a given string by n places, typically used with 13 on upper case only text. This shifts each character by the value of the corresponding character in the key with a modulo for where the values overflow. Closest I can think of from the top of my head that also does this is Solitaire but that also has some complexities of its own.
Problem with this is that if 2 messages are sent using the same key it does become a rather trivial operation to reverse engineer the key and from that the messages.
I'm fully aware that JavaScript and Java are two different languages, I mock people for thinking that all the time.

And it is ROT, just not how it normally works. Instead of being based on the alphabet (abcd...wxyz) it's based on ASCII character codes. Let's say your key is "435" and your text is "this will become rotated". This is how the text will be rotated:
t h i s   w i l l   b e c o m e   r o t a t e d
4 3 5 4 3 5 4 3 5 4 3 5 4 3 5 4 3 5 4 3 5 4 3 5
The ASCII code for "t" is 116. Add four to that, and you get 120. The ASCII character at number 120 is "x".
"h"->104->107->"k"
"i"->105->110->"n"
...and so on.

#9 RoD

  • Members
  • 313 posts

Posted 02 April 2014 - 04:38 PM

The function that bomb bloke wrote works fine but i can't use it in my code.
Is there anyone who already devolped an app or that know about the android app devolpment? I mean, i did everything like it should be and i tried various ways.
If somone can help that would be really apreciated :)
And thanks to the ones that are already helping me :)





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users