PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 24 → Webservices - versao final
Webservices - versao final
Débuté par adrianoboller, 03 déc. 2014 16:22 - 1 réponse
Membre enregistré
2 958 messages
Popularité : +89 (91 votes)
Posté le 03 décembre 2014 - 16:22
Membre enregistré
2 958 messages
Popularité : +89 (91 votes)
Posté le 06 mai 2016 - 22:01
WS_Criptografia

Procedure WS_Criptografia(LOCAL Valor, LOCAL CD, LOCAL DebugSN)
//Exemplo Criptografia
//2-JOAO-JOAO-123890 = valor = cript
//A-B-TYKY-TYKY-ABCHIJ = retorno = decript

//InicializaVariaiveis
i,j, t is int = 0
retorno, alfa is string = ""
cript is array of string
decript is array of string

//Define se é Randomico entre 1,2,3
ResRandom is int = Random(1, 3)

IF ResRandom = 0 THEN
ResRandom = 1
END

Valor = Upper(Valor)
CD = Upper(CD)

IF DebugSN = "S"
Info(ResRandom,Valor,CD)
END

//Configuracao
criptA is array of string = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ]
decriptA is array of string = [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" ]

criptB is array of string = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ]
decriptB is array of string = [ "Z", "Y", "X", "W", "V", "U", "T", "S", "R", "Q", "P", "O", "N", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A", "8", "7", "6", "5", "4", "3", "2", "1", "9", "0" ]

criptC is array of string = [ "1", "2", "3", "4", "5", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "6", "7", "8", "9", "0", "Y", "Z" ]
decriptC is array of string = [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "9", "8", "7", "6", "5", "4", "3", "2", "1" ]


//Cript
IF CD = "C" THEN // Criptografar

SWITCH ResRandom
CASE 1 //A
cript = criptA
decript = decriptA
retorno = "A-"
CASE 2 //B
cript = criptB
decript = decriptB
retorno = "B-"
CASE 3 //C
cript = criptC
decript = decriptC
retorno = "C-"
OTHER CASE //A
cript = criptA
decript = decriptA
retorno = "A-"
END//FimSwitch

//Criptografar
IF Valor <> "" THEN

//Exemplo Criptografia
//2-JOAO-JOAO-123890 = valor = cript
//A-B-TYKY-TYKY-ABCHIJ = retorno = decript

//Leitura do Valor Passado
t = Length(Valor) // Quantidade de caracter
LOOP (t) //Leitura do Valor Passado

i+= 1

IF Middle(Valor,i,1) <> "-" THEN //2 na 1

LOOP (36) //Leitura do cript de 36 posicoes

j += 1

alfa = Middle(Valor,i,1)

IF alfa = decript[j] THEN
BREAK
END

END//Loop

retorno += cript[j]
j = 0

ELSE

retorno += "-"

END//if

END//Loop

ELSE
Info("Valor em branco!...")
END
RESULT(retorno)

ELSE IF CD = "D" THEN // Descriptografar

SWITCH Middle(Valor,1,1)
CASE "A"
cript = criptA
decript = decriptA
CASE "B"
cript = criptB
decript = decriptB
CASE "C"
cript = criptC
decript = decriptC
OTHER CASE //A
cript = criptA
decript = decriptA
END//FimSwitch

//Remove o 1o e 2o caracter
Valor = Middle(Valor,3,Length(Valor))

//Descriptografar
IF Valor <> "" THEN

//Exemplo Criptografia
//2-JOAO-JOAO-123890 = valor = cript
//A-B-TYKY-TYKY-ABCHIJ = retorno = decript

//Leitura do Valor Passado
t = Length(Valor) // Quantidade de caracter
LOOP (t) //Leitura do Valor Passado

i+= 1

IF Middle(Valor,i,1) <> "-" THEN //2 na 1

LOOP (36) //Leitura do cript de 36 posicoes

j += 1
alfa = Middle(Valor,i,1)

IF alfa = cript[j] THEN
BREAK
END

END//Loop

retorno += decript[j]
j = 0

ELSE

retorno += "-"

END//if

END//Loop

ELSE
Info("Valor em branco!...")
END
RESULT(retorno)

END


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