Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Converting string to long

Converting string to long

Scheduled Pinned Locked Moved C / C++ / MFC
help
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vgandhi
    wrote on last edited by
    #1

    Hey guys, I am using this code to convert the data into string CryptBinaryToString((BYTE *)pBufPtr,len,1,msg2,&lul_buflen); The msg2 looks like "KBeMW9yLvHwMow5dKCXO3ddKLzIGQTmbtNVmmFF2FmT9/f39q6urq6urq6vu/u7+" and I am using the following functions to convert the string to long so that I can reduce the size to be displayed on the string char *p; long l = strtol(msg2, &p, 10); long temp1 = atoi(msg2); But both of them return 0 as the value. Please help. vg

    C 1 Reply Last reply
    0
    • V vgandhi

      Hey guys, I am using this code to convert the data into string CryptBinaryToString((BYTE *)pBufPtr,len,1,msg2,&lul_buflen); The msg2 looks like "KBeMW9yLvHwMow5dKCXO3ddKLzIGQTmbtNVmmFF2FmT9/f39q6urq6urq6vu/u7+" and I am using the following functions to convert the string to long so that I can reduce the size to be displayed on the string char *p; long l = strtol(msg2, &p, 10); long temp1 = atoi(msg2); But both of them return 0 as the value. Please help. vg

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      :confused: Uuh ?? This doesn't represent a number ! There are letters in it, how could this be translated to a number ? The functions will stop as soon as a non numerical symbol will be detected, in this case this is the first one (K), so the functions return 0. Why do you want to reduce its size and why do you want to convert it into a number ??


      Cédric Moonen Software developer
      Charting control [v1.1]

      V 1 Reply Last reply
      0
      • C Cedric Moonen

        :confused: Uuh ?? This doesn't represent a number ! There are letters in it, how could this be translated to a number ? The functions will stop as soon as a non numerical symbol will be detected, in this case this is the first one (K), so the functions return 0. Why do you want to reduce its size and why do you want to convert it into a number ??


        Cédric Moonen Software developer
        Charting control [v1.1]

        V Offline
        V Offline
        vgandhi
        wrote on last edited by
        #3

        Basically I the encrypted binary data I want to convert to a string and display it as a challenge to the user who can read it out to the admin user who can use that challenge to create the response. So I need to convert that string into a decent size number or maybe string itself is fine that can be displayed to the user. Thanks.

        vg

        C M D 3 Replies Last reply
        0
        • V vgandhi

          Basically I the encrypted binary data I want to convert to a string and display it as a challenge to the user who can read it out to the admin user who can use that challenge to create the response. So I need to convert that string into a decent size number or maybe string itself is fine that can be displayed to the user. Thanks.

          vg

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          Well, once you get the encrypted string, you cannot reduce it any further (and even not change it). So your problem is before, already at the encryption. And I don't know how you can change the size of the encrypted string.


          Cédric Moonen Software developer
          Charting control [v1.1]

          1 Reply Last reply
          0
          • V vgandhi

            Basically I the encrypted binary data I want to convert to a string and display it as a challenge to the user who can read it out to the admin user who can use that challenge to create the response. So I need to convert that string into a decent size number or maybe string itself is fine that can be displayed to the user. Thanks.

            vg

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            The string in your OP is a representation of the encrypted data, it's base-64 encoded. You'll need to be more precise about what you mean by "convert that string into a decent size"

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ"); Ford, what's this fish doing in my ear?

            V 1 Reply Last reply
            0
            • M Michael Dunn

              The string in your OP is a representation of the encrypted data, it's base-64 encoded. You'll need to be more precise about what you mean by "convert that string into a decent size"

              --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ"); Ford, what's this fish doing in my ear?

              V Offline
              V Offline
              vgandhi
              wrote on last edited by
              #6

              What I mean by that is say the entire string is of 25 size I need to conver that to 10 or maybe less so that when it is displayed on the screen to the user, the user can take that string and read it out to Admin. Hope this makes it clear. Thanks.

              vg

              M 1 Reply Last reply
              0
              • V vgandhi

                Basically I the encrypted binary data I want to convert to a string and display it as a challenge to the user who can read it out to the admin user who can use that challenge to create the response. So I need to convert that string into a decent size number or maybe string itself is fine that can be displayed to the user. Thanks.

                vg

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                vgandhi wrote:

                Basically I the encrypted binary data I want to convert to a string and display it...

                So just display it in encrypted format (i.e., string).


                "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                "Judge not by the eye but by the heart." - Native American Proverb

                V 1 Reply Last reply
                0
                • D David Crow

                  vgandhi wrote:

                  Basically I the encrypted binary data I want to convert to a string and display it...

                  So just display it in encrypted format (i.e., string).


                  "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                  "Judge not by the eye but by the heart." - Native American Proverb

                  V Offline
                  V Offline
                  vgandhi
                  wrote on last edited by
                  #8

                  My friend how can I display it in encrypted format to the user. The user won't understand anything.

                  vg

                  D 1 Reply Last reply
                  0
                  • V vgandhi

                    My friend how can I display it in encrypted format to the user. The user won't understand anything.

                    vg

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    vgandhi wrote:

                    My friend how can I display it in encrypted format to the user. The user won't understand anything.

                    This makes no sense. The whole purpose for encryption is so that "it" is not understandable.


                    "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                    "Judge not by the eye but by the heart." - Native American Proverb

                    1 Reply Last reply
                    0
                    • V vgandhi

                      What I mean by that is say the entire string is of 25 size I need to conver that to 10 or maybe less so that when it is displayed on the screen to the user, the user can take that string and read it out to Admin. Hope this makes it clear. Thanks.

                      vg

                      M Offline
                      M Offline
                      Michael Dunn
                      wrote on last edited by
                      #10

                      If you want a shorter human-readable string, you'll need to have less encrypted data.

                      --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ"); Ford, what's this fish doing in my ear?

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups