Encryption seems like too much returns error when decrypting

CodeViperCodeViper Member Posts: 28
I am looking for is a simple 'jumble/encryption' so prying eyes cant read a field.

I tried using the built in Encryption which encrypted the text string, but Decryption failed with a long error and complaining that it couldn't because of double padding or something like that.

Basically looking for a mask of sort.
want to take "Purchase Order 123ABC" and mask it to "u7r4yt64y9y". *example*
BUT... then when I have "u7r4yt64y9y" in the field and want to read it back, i want it to 'unmask' and be "Purchase Order 123ABC" again.

Anyone have a function that can do that...???

Best Answer

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    edited 2018-05-14 Answer ✓
    You can read about ROT-13 'encryption' alghoritm here: https://en.wikipedia.org/wiki/ROT13

    A simple function doing ROT-13 may look like this:
    ROT13(aText : Text) oText : Text
    oText := aText;
    FOR i := STRLEN(aText) DOWNTO 1 DO
      CASE TRUE OF 
        oText[i] IN ['A'..'M', 'a'..'m'] : oText[i] += 13;
        oText[i] IN ['N'..'Z', 'n'..'z'] : oText[i] -= 13;
      END;
    
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03

Answers

  • aceXaceX Member Posts: 165
    Hi there @CodeViper

    Why do you have to encrypt the data, why you just simply work with permissions in here. If the user should not see the value in the field hide the value for him. If you check your new field in User Setup table for that user so he can see the value, the value will be shown.
    For additional information you can read this post:

    https://forum.mibuso.com/discussion/comment/314243#Comment_314243

    Solution provided by @carbon

    Regards
  • CodeViperCodeViper Member Posts: 28
    because i am emailing the information... hence why i want it to be 'masked' once it leaves...
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    How strong should the encryption be? If it is only to masking and you don't really care how easy is to decrypt it you could write simple ROT-13 on your string, or more advanced custom 'encryption' - say add a position of each character in a string to its value.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • CodeViperCodeViper Member Posts: 28
    sorry Slawek, i am unfamiliar with ROT-13.. .could you give me a code sniplet/example of what you mean?
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    edited 2018-05-14 Answer ✓
    You can read about ROT-13 'encryption' alghoritm here: https://en.wikipedia.org/wiki/ROT13

    A simple function doing ROT-13 may look like this:
    ROT13(aText : Text) oText : Text
    oText := aText;
    FOR i := STRLEN(aText) DOWNTO 1 DO
      CASE TRUE OF 
        oText[i] IN ['A'..'M', 'a'..'m'] : oText[i] += 13;
        oText[i] IN ['N'..'Z', 'n'..'z'] : oText[i] -= 13;
      END;
    
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • CodeViperCodeViper Member Posts: 28
    Thanks Slawek... that is EXACTLY what i was looking for... *two thumbs up* thank you!!!
Sign In or Register to comment.