Skip to content

Instantly share code, notes, and snippets.

@mukasc
mukasc / TripleDES.java
Created June 12, 2020 13:57
TripleDES
package br.com.delsoftsistemas;
import br.com.delsoftsistemas.comum.FuncoesComuns;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import org.apache.commons.codec.binary.Base64;
USE gx_kb_atual
DECLARE @tabela VARCHAR(500) = 'RHF_ColabIntermitenteItem';
DECLARE @sql NVARCHAR(4000);
SELECT @sql = comandosql FROM DELSOFTX_TABELA(@tabela)
USE fanavid
EXEC(@sql)
* CAMPOS
USE gx_kb_atual
DECLARE @coluna VARCHAR(500) = 'RHF_COLABINTERCALCULADO';
DECLARE @sql NVARCHAR(4000);
create FUNCTION DELSOFTX_PK (@tabela char(50))
RETURNS TABLE
AS
RETURN
(
SELECT posicao, tb, campo
FROM (
SELECT c.obj_name as tb, b.attri_name as campo, e.attri_type as tipo, e.length as tamanho, e.decimals as decimais, 1 AS iskey,
a.position_ck+1 AS posicao
FROM CK_ATRI a
param (in:&CallHash,
in:&SdtMacroAnswers,
in:&UserCelphone,
in:&ModuloERP,
inout:&Place,
inout:&NextPlace,
in:&Provider,
out:&WSPlace,
out: &Json_Out);
sem parm
main program = true
call protocol = HTTP
java try{
do 'AnnaParametros'
&LinkWSIntegracao = &TEC_AnnaParamWSIntegracao
&LinkWSCallBack = &TEC_AnnaParamWSCallBack
Parm(In: &Json, In: &EncKEY, In: &DecKEY, In: &IV, Out: &StringResponse);
&NewIV = &DelsoftTripleDES.gxcriaIvDummy()
&NewIVCript = TEC_AnnaEncryptTripleDES.Udp(&NewIV, &DecKEY, &IV)
&Retorno = TEC_AnnaEncryptTripleDES.Udp(&Json, &EncKEY, &NewIV)
&StringResponse = &Retorno + '' + &IV + '' + &NewIVCript
Parm(In:&Text, In:&Key, In:&IV, Out:&OutText);
//Decrypted using the TripleDES algorithm using CBC mode (Cipher Block Chaining).
&OutText = &DelsoftTripleDES.gxdecrypt(&Text, &Key, &IV)
Parm(In:&Text, In:&Key, In:&IV, Out:&OutText);
//Encrypted using the TripleDES algorithm using CBC mode (Cipher Block Chaining).
&OutText = &DelsoftTripleDES.gxencrypt(&Text, &Key, &IV)
Parm(
in:&WSPlace,
inout:&NextPlace,
inout:&Saudacao,
inout:&CallHash,
out:&json_out);
do 'AnnaParametros'
&LinkWSIntegracao = &TEC_AnnaParamWSIntegracao
&LinkWSCallBack = &TEC_AnnaParamWSCallBack
parm(out:&CallHash);
&Agora = now()
&AgoraStr = &Agora.Year().ToString().Trim()
&AgoraStr += substr(trim(str(&Agora.Month() + 100)),2,2)
&AgoraStr += substr(trim(str(&Agora.Day() + 100)),2,2)
&AgoraStr += substr(trim(str(&Agora.Hour() + 100)),2,2)
&AgoraStr += substr(trim(str(&Agora.Minute() + 100)),2,2)
&AgoraStr += substr(trim(str(&Agora.Second() + 100)),2,2)
&RandomStr = trim(str(int(Random()*9)))