Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3996592
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:17:53+00:00 2026-05-20T07:17:53+00:00

We have a program on our AS400 that takes in a number, encrypts it

  • 0

We have a program on our AS400 that takes in a number, encrypts it and then passes the encrypted characters back. Using the CWBX stringConverter.FromBytes method… I am able to convert the numberic byte / ascii code value, into its appropriate character. This has been working fine for a while, until we noticed some values getting cut off.

The byte array returned looks like this:
(70, 126, 135, 27, 0, 201, 222, 229, 52, 75, 61, 121, 34, 65, 113, 215)

Where 240 = “0”, 241 = “1”, 64 = [Blank Space], etc… The problem is with the 5th byte being equal to zero. This is [Null].
Therefore instead of seeing something like: #^!@ 7′<“&$#T~*(
I am instead seeing: #^!@
Because the 5th character element is [Null],it escentially cuts off that character as well as the rest of my string!

Normally, i would just check for the byte element = 0, and then do something else. The only problem is, i have to insert this data into a database so that it can be decrypted later on, so i cannot alter the character and change it to lets say an “#” character.

I have tried looping through each value, and if the byte equals zero then appending vbNull onto the string, but then when its decrypted it does not come back as the same byte ascii code “0”, it comes back as “241” which is vbNull.

Here is my current code:

Dim as400 As cwbx.AS400System
as400 = New cwbx.AS400SystemClass()
Dim program As cwbx.Program = New cwbx.Program()
Dim strResult(1) As String

as400.Define(RPGServer)
program.system = as400
program.system.UserID = RPGUsername
program.system.Password = RPGPassword
program.LibraryName = CurrentLibrary
program.ProgramName = EncryptionProgram

If as400.IsConnected(cwbx.cwbcoServiceEnum.cwbcoServiceRemoteCmd) = 0 Then
    as400.Disconnect(cwbx.cwbcoServiceEnum.cwbcoServiceAll)
    as400.Connect(cwbx.cwbcoServiceEnum.cwbcoServiceRemoteCmd)
End If

Dim stringConverter As cwbx.StringConverter = New cwbx.StringConverterClass()
Dim parameters As cwbx.ProgramParameters = New cwbx.ProgramParametersClass()

stringConverter.Length = 16

parameters.Append("&INNUM", cwbx.cwbrcParameterTypeEnum.cwbrcInput, 16)
parameters("&INNUM").Value = stringConverter.ToBytes(CardNo.PadRight(16, " "))

parameters.Append("&OUTNUM", cwbx.cwbrcParameterTypeEnum.cwbrcOutput, 16)

program.Call(parameters)

strResult(0) = stringConverter.FromBytes(parameters("&OUTNUM").Value)

And here is what I tried with changing the character:

stringConverter.Length = 16
Dim byteArr() As Byte = {22, 11, 57, 27, 0, 221, 252, 143, 52, 54, 66, 72, 31, 65, 24, 77}

Dim strValue As String = ""
For Each b As Byte In byteArr
    stringConverter.Length = 1
    If b = 0 Then
        strValue &= vbNull
    Else
        Dim tbb2() As Byte = {b}
        strValue &= stringConverter.FromBytes(tbb2)
    End If
Next
stringConverter.Length = 16

Dim tttt As Byte() = stringConverter.ToBytes(strValue)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:17:53+00:00Added an answer on May 20, 2026 at 7:17 am

    Do not convert a byte[] to a string with an EBCDIC string converter. While 0 is a perfectly reasonable byte value, it often acts as a string terminator. It does so for the debugger (note the missing trailing double quote), it isn’t unlikely to do so as well for your dbase provider. If you don’t want to store the value as a binary blob in the dbase then encode it with Convert.ToBase64String(). Read it back with Convert.FromBase64String().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that does some networking using Winsock, and one of our
I have a CAB file that installs our program to Windows CE. I have
I have a program that will let me manage users on our terminal server
We have an app that currently installs itself into 'program files\our app', and it
I have program that runs fast enough. I want to see the number of
I have a program that uploads files to our server when they are dropped
We have a program that uses QoS-sockets, our softphone application uses QoS for the
I have a program that searches a file (numbers.dat) using a binary search and
Our program so far: We have a process that involves multiple schemata, orchestrations and
I have a program that we use to connect our Magento store to our

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.