Encrypt Messages

dfragosodfragoso Member Posts: 18
edited 2010-08-23 in NAV Tips & Tricks
A way to encrypt messages, this code change the order of the message and change some letters for other symbols.


OnRun()
/////////////Encrypt Messages///////////


//Message
TextMessage := 'This message is encrypted';
Length := STRLEN(TextMessage);


//Message Encryption
i := Length;
REPEAT
Letter := COPYSTR (TextMessage,i ,1 );
ReverseMessage := ReverseMessage + Letter;
i := i - 1;
UNTIL i = 0;

EncryptedMessage := CONVERTSTR(ReverseMessage, 'AEIOUaeiou', 'º*!"#$.ç()');

MESSAGE(EncryptedMessage);


//Message Decryption
i := Length;
REPEAT
Letter := COPYSTR (EncryptedMessage,i ,1 );
ReverseMessage2 := ReverseMessage2 + Letter;
i := i - 1;
UNTIL i = 0;

EncryptedMessage := CONVERTSTR(ReverseMessage2, 'º*!"#$.ç()', 'AEIOUaeiou');

MESSAGE(EncryptedMessage);

Comments

  • krikikriki Member, Moderator Posts: 9,112
    But do you have a question about it or do yo mean it as a tip&trick?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • dfragosodfragoso Member Posts: 18
    kriki wrote:
    But do you have a question about it or do yo mean it as a tip&trick?

    I mean it as a tip&trick, sorry for put it in wrong section.
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • vytjakvytjak Member Posts: 36
    Well, when I needed some quick and trivial way to encrypt a text string I just XOR'ed it. Also, you don't need to use COPYSTR().

    In my version, the main loop looks something like this:
    //Message Encryption 
    l := Length; 
    for i := 1 to Length do
      TextMessage[i] := 255 - TextMessage[i]; 
    

    And run the same loop one more time to decrypt the text.

    Just to make it clear: in NO way this is an example of at least basic security measure.
    Vytenis Jakas
    B3 Technologies - Making Technology Serve the People
  • ara3nara3n Member Posts: 9,256
    Hello, here is a post on how to encrypt/decrypt using SQL.

    http://mibuso.com/blogs/ara3n/2009/05/2 ... -with-ado/
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ShonatinaShonatina Member Posts: 114
    vytjak wrote:
    //Message Encryption 
    l := Length; 
    for i := 1 to Length do
      TextMessage[i] := 255 - TextMessage[i]; 
    


    hi there...
    i just came cross this post, so pardon me for the very late query on this topic. but please can you explain a bit more about this technique...

    thanks in advance :)
    smile always
    shona
    That which you seek inside is that which you find outside
  • AntidotEAntidotE Member Posts: 61
    Shonatina wrote:
    vytjak wrote:
    //Message Encryption 
    l := Length; 
    for i := 1 to Length do
      TextMessage[i] := 255 - TextMessage[i]; 
    


    hi there...
    i just came cross this post, so pardon me for the very late query on this topic. but please can you explain a bit more about this technique...

    thanks in advance :)

    Pretty simple.
    Every character has it's number in ASCII table. Max value is 255. Min value is 0.
    We go through all characters of the string and make another character by subtracting it's number from 255.
    e.g. we have string 'ABC', in ASCIIcodes it will be numbers 65 66 67, after our cycle we'll have symbols wih numbers 190 189 188 => string '╛╜╝'.
    It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.
Sign In or Register to comment.