How would encryption programs work?

What would you have to know to make a encryption program using delphi?Like what to impliment into the program.Also how does other encryption programs work like this.This is going to be a very basic program which will

encrypt only letters of the alphabet and text.

2 Answers

Relevance
  • 8 years ago
    Best Answer

    In short, characters are represented on computers as numeric values (bits). So, encryption cyphers work by doing math on these (characters) numbers to produce new and different (characters) numbers. By example, a simple XOR encryption cipher (see below) is one of the simplest methods of cypher, and demonstrates how a password (or Key) is used in conjunction with data to calculate new encrypted data.

    *NOTE* CRC & MD5 hashing algorithms are not an example of encryption as such, though they can be used to calculate check-sums for large quantities of data; some think reliably too.

    The example code should work just fine in Delphi if you want to see it in action. Just paste the code in and call the function with the required parameters.

    function EnDeCrypt(Str, Pwd: string): string;

    var i,j: integer;

    begin

    {function to encrypt / decrypt a string using simple xor}

    if Length(Str) > 0 then

    begin

    i:=1; j:=1;

    while i < Length(Str) do

    begin

    Str[i] := Char(not(Ord(Str[i]) XOR Ord(Pwd[j])));

    if j = Length(Pwd) then

    j := 1 else inc(j);

    inc(i);

    end; {while}

    end; {if}

    EnDeCrypt := Str;

    end; {}

    I've written other cyphers including Vigenere's cipher should you need something more complex. As already stated, you can download code (for Delphi, not C++) that you can use directly.

    Mystic

  • 8 years ago

    As far as i know, encryption utilities work by receiving information stored as variables and converting the into a hash, which is an obfuscated value that can only be used by your utility. There are probably algorithms you could use in the form of a function in C++, Java, etc. There is, however, an inbuilt function in PHP called 'md5', which will hash any value given to it [md5("$password"), for example].

Still have questions? Get your answers by asking now.