PC SOFT
ONLINE REPOSITORY
FOR WINDEVWEBDEV AND WINDEV MOBILE

Home |  | Sign in | English US
Sample Toquen
Published by Boller
in the category Tools
New features
Sample Toquen use in app mobile in webservice

Description
Sample Toquen use in app mobile in webservice:

MAIS INFORMAÇÕES
Adriano José Boller
Consultor, Representante e Distribuidor Oficial PC SOFT
Email: adrianoboller@gmail.com
Telefone: +55 (41) 99949-1800
Skype: adrianoboller
Horário: Segunda—sexta: 8h–18h
Sábados & domingos: 11h–15h


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
Illustrations, screen shots
none
none
User reviews
(To evaluate this resource, click 'Write a review')
No review or comment? Be the first one!