PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → WX (Windev, Webdev e Windev Mobile) - Cálculo do Pix para QRCODE
WX (Windev, Webdev e Windev Mobile) - Cálculo do Pix para QRCODE
Débuté par Boller, 02 juin 2021 23:34 - 2 réponses
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 02 juin 2021 - 23:34
Boa noite a todos

Abaixo segue o código enviado pelo Paulo Viana

Procedure rot_pix(chave)

meuvalor is string=chave

nTamanho is int = Length(meuvalor)
nPoly is 2-byte unsigned int = 0x1021
Wcrc is 2-byte unsigned int = 0xFFFF

FOR i=1 _TO_ Length(meuvalor)
Wcrc = BinaryXOR(Wcrc, Asc(meuvalor[[i]]) bitLeftShift 8)
FOR j = 0 TO 7
IF (Wcrc & 0x8000) THEN
Wcrc=(Wcrc bitLeftShift 1) || 0x1021
ELSE
Wcrc=Wcrc bitLeftShift 1
END
END
END

RESULT(chave+IntToHexa(Wcrc)[[5 TO ]])


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 02 juin 2021 - 23:43




muito obrigado Paulo Viana da i9 sempre ajudando com exemplos

show de bola

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 20 août 2022 - 15:03
//NOVO CODIGO

IF EDT_Valor <= 0 THEN
Info("Informe Um Valor Válido")
ReturnToCapture(EDT_Valor)
ELSE
cyValorDoc is currency = EDT_Valor
sCChavePix is string = "+5591984311845"
sIdentificacao is string = "JOSE WILLEM DO NASCIMENTO" // Nome do beneficiário (até 25 letras)
sCidade is string = "BELEM"
sCEP is string = "66625410"
sDoc is string = "000000164"
//sDoc = // Initializes the generator of random numbers
InitRandom()

sRandomString is string

// Generates the random string
LOOP (25)

// Generates a number at random in the 65-122 (A-z) interval
nCharacter is int = Random(65,122)
// Don't take the characters included between 91 and 96
WHILE (91 <= nCharacter <= 96)
nCharacter = Random(65,122)
END

// Fills the string
sRandomString += Charact(nCharacter)
END

sRandomString = "abc56897xbxs6565ssw89"
EDT_Identificador = sRandomString


sDoc = sRandomString

sString is string = ""

sMsg is string = "05" + NumToString( Length( NoSpace( Left( NoSpace(sDoc),21))),"02d") + Left(NoSpace(sDoc),21)

nTamChave is int = 22 + Length(NoSpace(sCChavePix))

sString = "000201" //Inicio do código para gerar o Qr-Code
sString += "26" + NumToString(nTamChave,"02d") + "0014br.gov.bcb.pix01" + NumToString( Length( NoSpace( sCChavePix )),"02d") + NoSpace( sCChavePix )
sString += "52040000"
sString += "5303986"

// essa linha que tem que ser alterada
sString += "54" + NumToString( Length( NoSpace( NumToString(cyValorDoc,"10.2f"))),"02d") + NoSpace(NumToString(cyValorDoc,"10.2f"))

sString += "5802BR"
sString += "59" + NumToString( Length( NoSpace( sIdentificacao )),"02d") + NoSpace( sIdentificacao )
sString += "60" + NumToString( Length( Left (NoSpace( sCidade),15)),"02d") + NoSpace( Left( sCidade,15))
sString += "62" + NumToString( Length( sMsg), "02d" ) + sMsg
sString += "6304"
sString = Rot_Pix(sString)
EDT_Pix = sString

ToClipboard(sString)

BAC_Pix.Value = sString


ImageQRCodeCenter is Image
ImageQRCodeCenter = IMG_FLAG

MyBarCode is BarCode
MyBarCode.Content = sString
MyBarCode.TypeBarCode = BC_QRCODE
MyBarCode.Image = ImageQRCodeCenter
MyBarCode.CorrectionError = qrcodeLevelH
MyBarCode.ImageProportion= 3

ImageBarCode is Image = BCToImage(MyBarCode,200,200)

IMG_Pix = ImageBarCode

END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/