Jump to content

Most Secure Algorithms?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
When it comes to encryption, when security is vital, I mean a very important thing, not just a password for your email lol, how do they develop complicated algorithms.. as complicated as it could?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
A lot of the secure algorithms aren't very complicated. They ARE resistant to easily determining the input from the output. Most of the algorithms are generated by mathematicians. The most important aspect of a secure algorithm is that a minor change should produce radically different output, making it harder to determine from the encoded object what the source was.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

WingedPanther said:

The most important aspect of a secure algorithm is that a minor change should produce radically different output, making it harder to determine from the encoded object what the source was.

Like what? like for example inserting an extra 'a' would output like another 10 characters? or what?

#4
Maurice_Z

Maurice_Z

    Learning Programmer

  • Members
  • PipPipPip
  • 41 posts
It could be something like:
every character has a code ranging from 0-255.
I have two variables:
Nochars - Number of characters
Sumochars - sum of the numbers of characters, always being the module of 255.
I write the first character as byte, then I increase Nochars by One and Sumochars by the Byte representation of that character (So for example "8" has cahracter code 056 or 38 as Hexademical).
After that I look at next character. And I do something like this:
CharacterCode=(Nochars*Sumochars+CharacterCode) Mod 255
Then I write the character as byte, increase Nochars by one and increase Sumochars by CharacterCode. And so it goes, until all characters are finished.
This is of course a simple security, but you can easily make it harder by using more mathematical stuff and more complicated mathematical stuff.
This thing is good for Securing simple strings, which aren't crucial meaning, but you don't want for example to make player ruin their fun by looking into files.

To secure variables, for example to store scores in files, you can do something like this:
[B]score[/B] - Score
[b]sec1score[/b] - (score+10)*5-1
[b]sec2score[/b] - (score-15)*7+60
[b]sec3score[/b] - score*2-1
And write results in file. When trying to retrieve the variables, you work backwards:
[b]desec1score[/b] - (sec1score+1)/5-10
[b]desec2score[/b] - (sec2score-60)/7+15
[b]desec3score[/b] - (sec3score+1)/2
and then compare all results. if they are different, either the code is wrong, or someone tried to alter the variables.
However you have to keep in mind, that using Dividing while securing might result in fractional parts, which may lead to error, so for your own sake do not divide while Securing(Crypting?). An example of problem:
score=10
sec1score=10/3+1 (Thus it gives 4.333333)
desec1score=(4.33333-1)*3=3.33333*3=9.999999
desec1score is not equal to score.

I hope I didn't miss the point and said something not according to the topic ^^;

#5
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

Maurice_Z said:

I hope I didn't miss the point and said something not according to the topic ^^;

No no man. That is very helpful!

Really thanks for your help :)

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts

TheComputerMaster said:

Like what? like for example inserting an extra 'a' would output like another 10 characters? or what?

More like inserting an extra 'a' at the end adds a few more chars and radically changes the produced chars around it. Here's an example:

DES encryption: key = '12345678'
message1 = 'message'
Result1 = '0x67a7087317546139'

message2 = 'messagea'
Result2 = '0xb126aebf47ea913f'

You can look at examples here: Testing DES
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
That is a drastic change. Thanks for the clear explanation.