an encrypt arithmetic - IBM AS400

This is a discussion on an encrypt arithmetic - IBM AS400 ; help! i need an encrypt arithmetic. such as aes or des. use in rpgle....

+ Reply to Thread
Results 1 to 5 of 5

Thread: an encrypt arithmetic

  1. an encrypt arithmetic

    help!
    i need an encrypt arithmetic. such as aes or des.
    use in rpgle.


  2. Re: an encrypt arithmetic


    snowcastle schrieb:

    > help!
    > i need an encrypt arithmetic. such as aes or des.
    > use in rpgle.


    IMHO the easiest way is to use the SQL scalar functions ENCRYPT_RC2
    (Release V5R3) or ENCRYPT_TDES (Release V5R4 - Tripple DES) to encrypt
    data and one the scalar functions DECRYPT_BIT, DECRYPT_BINARY,
    DECRYPT_CHAR, DECRYPT_DB to decrypt the encrypted data.

    In the first parameter you pass the data to be encrypted or decrypted
    and in the second one the password.

    Here is an example:

    D MyData S 20A inz('Birgitta')
    D MyEncryptData S 50A
    D MyDecryptData S 20A
    D MyPassWord S 10A

    *---------------------------------------------------------------------------------------------
    C MyData Dsply

    C/EXEC SQL Set :MyEncryptData = EnCrypt_RC2(:MyData, 'Hauser')

    C/End-Exec

    C MyEncryptData Dsply

    C Eval MyPassWord = 'Hauser'

    C/EXEC SQL Set :MyDecrypt = DeCrypt_Char(:MyEncrypt, Trim(:MyPassWord))

    C/End-Exec

    C MyDecryptData Dsply

    C eval *InLR = *on


    If this is not enough for you, you may check the cryptographic services
    APIs
    http://publib.boulder.ibm.com/infoce...s/catcrypt.htm

    Birgitta


  3. Re: an encrypt arithmetic

    I use v5r1,hehe.cannot compile.
    can u have others solutions?
    Birgitta.Hauser@lp-gmbh.com write:

    > snowcastle schrieb:
    >
    > > help!
    > > i need an encrypt arithmetic. such as aes or des.
    > > use in rpgle.

    >
    > IMHO the easiest way is to use the SQL scalar functions ENCRYPT_RC2
    > (Release V5R3) or ENCRYPT_TDES (Release V5R4 - Tripple DES) to encrypt
    > data and one the scalar functions DECRYPT_BIT, DECRYPT_BINARY,
    > DECRYPT_CHAR, DECRYPT_DB to decrypt the encrypted data.
    >
    > In the first parameter you pass the data to be encrypted or decrypted
    > and in the second one the password.
    >
    > Here is an example:
    >

    > D MyData S 20A inz('Birgitta')
    > D MyEncryptData S 50A
    > D MyDecryptData S 20A
    > D MyPassWord S 10A
    >
    > *---------------------------------------------------------------------------------------------
    > C MyData Dsply
    >
    > C/EXEC SQL Set :MyEncryptData = EnCrypt_RC2(:MyData, 'Hauser')
    >
    > C/End-Exec
    >
    > C MyEncryptData Dsply
    >
    > C Eval MyPassWord = 'Hauser'
    >
    > C/EXEC SQL Set :MyDecrypt = DeCrypt_Char(:MyEncrypt, Trim(:MyPassWord))
    >
    > C/End-Exec
    >
    > C MyDecryptData Dsply
    >
    > C eval *InLR = *on
    >

    >
    > If this is not enough for you, you may check the cryptographic services
    > APIs
    > http://publib.boulder.ibm.com/infoce...s/catcrypt.htm
    >
    > Birgitta



  4. Re: an encrypt arithmetic

    Search through the RPG-400L archives at http://www.mirange.com. There's
    an example using 128-bit AES that I wrote last year. The example has an
    error in it but if you read through the entire thread, you'll see the
    fix. This example uses the CIPHER MI which is documented at
    http://publib.boulder.ibm.com/iserie.../mi/CIPHER.htm.
    I don't think that the example uses a salt value but you can use the
    CIPHER MI to generate a secure random number that you can use as a salt
    value (make sure you store the salt value or you will not be able to
    decrypt the data). One other thing the example does not do is encrypt
    more than one block of data. It's actually pretty easy to do and the
    documentation I pointed you to talks about it.

    Matt

    snowcastle wrote:
    > I use v5r1,hehe.cannot compile.
    > can u have others solutions?
    > Birgitta.Hauser@lp-gmbh.com write:
    >
    > > snowcastle schrieb:
    > >
    > > > help!
    > > > i need an encrypt arithmetic. such as aes or des.
    > > > use in rpgle.

    > >
    > > IMHO the easiest way is to use the SQL scalar functions ENCRYPT_RC2
    > > (Release V5R3) or ENCRYPT_TDES (Release V5R4 - Tripple DES) to encrypt
    > > data and one the scalar functions DECRYPT_BIT, DECRYPT_BINARY,
    > > DECRYPT_CHAR, DECRYPT_DB to decrypt the encrypted data.
    > >
    > > In the first parameter you pass the data to be encrypted or decrypted
    > > and in the second one the password.
    > >
    > > Here is an example:
    > >

    > > D MyData S 20A inz('Birgitta')
    > > D MyEncryptData S 50A
    > > D MyDecryptData S 20A
    > > D MyPassWord S 10A
    > >
    > > *---------------------------------------------------------------------------------------------
    > > C MyData Dsply
    > >
    > > C/EXEC SQL Set :MyEncryptData = EnCrypt_RC2(:MyData, 'Hauser')
    > >
    > > C/End-Exec
    > >
    > > C MyEncryptData Dsply
    > >
    > > C Eval MyPassWord = 'Hauser'
    > >
    > > C/EXEC SQL Set :MyDecrypt = DeCrypt_Char(:MyEncrypt, Trim(:MyPassWord))
    > >
    > > C/End-Exec
    > >
    > > C MyDecryptData Dsply
    > >
    > > C eval *InLR = *on
    > >

    > >
    > > If this is not enough for you, you may check the cryptographic services
    > > APIs
    > > http://publib.boulder.ibm.com/infoce...s/catcrypt.htm
    > >
    > > Birgitta



  5. Re: an encrypt arithmetic

    3q
    yesterday,i read the CIPHER doc.it is too diffcult that i have no
    patient to understand it.
    i need a easiest way to encrypt a char have 250A and decrypt it.
    i want to use the BITXOR. but my os is v5r1 can not support it.
    i find a RC4 encrypt/decrypt algorithm, it can be compiled but can not
    be run.
    u can help me?i use a key, it can encrypt data, and the encrypted date
    can be decrypted to data.

    matt.haas@thomsonlearning.com wite:

    > Search through the RPG-400L archives at http://www.mirange.com. There's
    > an example using 128-bit AES that I wrote last year. The example has an
    > error in it but if you read through the entire thread, you'll see the
    > fix. This example uses the CIPHER MI which is documented at
    > http://publib.boulder.ibm.com/iserie.../mi/CIPHER.htm.
    > I don't think that the example uses a salt value but you can use the
    > CIPHER MI to generate a secure random number that you can use as a salt
    > value (make sure you store the salt value or you will not be able to
    > decrypt the data). One other thing the example does not do is encrypt
    > more than one block of data. It's actually pretty easy to do and the
    > documentation I pointed you to talks about it.
    >
    > Matt
    >
    > snowcastle wrote:
    > > I use v5r1,hehe.cannot compile.
    > > can u have others solutions?
    > > Birgitta.Hauser@lp-gmbh.com write:
    > >
    > > > snowcastle schrieb:
    > > >
    > > > > help!
    > > > > i need an encrypt arithmetic. such as aes or des.
    > > > > use in rpgle.
    > > >
    > > > IMHO the easiest way is to use the SQL scalar functions ENCRYPT_RC2
    > > > (Release V5R3) or ENCRYPT_TDES (Release V5R4 - Tripple DES) to encrypt
    > > > data and one the scalar functions DECRYPT_BIT, DECRYPT_BINARY,
    > > > DECRYPT_CHAR, DECRYPT_DB to decrypt the encrypted data.
    > > >
    > > > In the first parameter you pass the data to be encrypted or decrypted
    > > > and in the second one the password.
    > > >
    > > > Here is an example:
    > > >

    > > > D MyData S 20A inz('Birgitta')
    > > > D MyEncryptData S 50A
    > > > D MyDecryptData S 20A
    > > > D MyPassWord S 10A
    > > >
    > > > *---------------------------------------------------------------------------------------------
    > > > C MyData Dsply
    > > >
    > > > C/EXEC SQL Set :MyEncryptData = EnCrypt_RC2(:MyData, 'Hauser')
    > > >
    > > > C/End-Exec
    > > >
    > > > C MyEncryptData Dsply
    > > >
    > > > C Eval MyPassWord = 'Hauser'
    > > >
    > > > C/EXEC SQL Set :MyDecrypt = DeCrypt_Char(:MyEncrypt, Trim(:MyPassWord))
    > > >
    > > > C/End-Exec
    > > >
    > > > C MyDecryptData Dsply
    > > >
    > > > C eval *InLR = *on
    > > >

    > > >
    > > > If this is not enough for you, you may check the cryptographic services
    > > > APIs
    > > > http://publib.boulder.ibm.com/infoce...s/catcrypt.htm
    > > >
    > > > Birgitta



+ Reply to Thread