Posté le 24 novembre 2014 - 12:26 |
Procedure WS_Criptografia(LOCAL Valor, LOCAL CD, LOCAL DebugSN)
i,j, t is int = 0 retorno, alfa is string = "" cript is array of string decript is array of string
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
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" ]
IF CD = "C" THEN
SWITCH ResRandom CASE 1 cript = criptA decript = decriptA retorno = "A-" CASE 2 cript = criptB decript = decriptB retorno = "B-" CASE 3 cript = criptC decript = decriptC retorno = "C-" OTHER CASE cript = criptA decript = decriptA retorno = "A-" END
IF Valor <> "" THEN
t = Length(Valor) LOOP (t)
i+= 1
IF Middle(Valor,i,1) <> "-" THEN
LOOP (36)
j += 1
alfa = Middle(Valor,i,1)
IF alfa = decript[j] THEN BREAK END
END
retorno += cript[j] j = 0
ELSE
retorno += "-"
END
END
ELSE Info("Valor em branco!...") END RESULT(retorno)
ELSE IF CD = "D" THEN
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 cript = criptA decript = decriptA END
Valor = Middle(Valor,3,Length(Valor))
IF Valor <> "" THEN
t = Length(Valor) LOOP (t)
i+= 1
IF Middle(Valor,i,1) <> "-" THEN
LOOP (36)
j += 1 alfa = Middle(Valor,i,1)
IF alfa = cript[j] THEN BREAK END
END
retorno += decript[j] j = 0
ELSE
retorno += "-"
END
END
ELSE Info("Valor em branco!...") END RESULT(retorno)
END |
| |
| |
|