CryptEncrypt function encrypting data which corrupts on writing into file. RRS feed

  • Question

  • Hi,

    For encryption, I use  "CryptEncrypt" and for decryption I use the  "CryptDecrypt".
    MSDN link:

    When I encrypt the string(mentioned below) I get the correct encrypted data(mentioned below) since decryption gives the original string but I have an issue when I write the encrypted string into the file.
    The encrypted string has "\n" at  10th position so the encrypted data after the position gets  newline in the file. When I decrypt data from the file it gives the wrong string.

    In memory

    Orig string : "layout(triangle_strip, max_vertices = 64) out;"
    Encrypted data : "™„³GÊÝ÷*#Þ\nÓ\xf*+\x16NÑçc~”d$d0ƒòÜæcä\t?\x4A6*&OõÓ¶\x19\x122"

    In File
    Encrypted :
    Ó*+NÑçc~”d$d0ƒòÜæcä ?A6*&OõÓ¶2


    Could you please suggest me how to tackle such issue?
    Thanks in advance.


    • Edited by NileshSrivastava Friday, March 3, 2017 9:13 AM Third party gramer correction tool written garbage words
    Friday, March 3, 2017 8:59 AM