criada a conexão com a api na api_get_pass.dart na tela tela login_screen.dart e feito a encrypt_password.dart
This commit is contained in:
20
lib/service/api_get_pass.dart
Normal file
20
lib/service/api_get_pass.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class ApiGetPass{
|
||||
Future apiConect(String? selectCity,String mode,String inputUser,String urlApi)async{
|
||||
String city = '';
|
||||
city = selectCity!.toLowerCase()
|
||||
.replaceAll('ú', 'u')
|
||||
.replaceAll('ç', 'c')
|
||||
.replaceAll('ó', 'o')
|
||||
.replaceAll('ô', 'o')
|
||||
.replaceAll('í', 'i')
|
||||
.replaceAll('ã','a');
|
||||
|
||||
final url = '$urlApi$mode/$city/pass/$inputUser';
|
||||
final response = await http.get(Uri.parse(url));
|
||||
final map = json.decode(response.body);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
43
lib/service/encrypt_password.dart
Normal file
43
lib/service/encrypt_password.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:gainer_crypto/crypto.dart';
|
||||
|
||||
class EncryptPassword{
|
||||
encrypt(String senhaDigitada,String senhaUsuario) {
|
||||
// Deixa e senha digitada em maiuscula
|
||||
var senha = senhaDigitada.toUpperCase();
|
||||
// Faz a criptografia da senha inserida
|
||||
String senhaMD5 = grHashString(GRCryptoType.md5, senha);
|
||||
// Retira o tipo (1, 2 ou 3) da senha do Usuário
|
||||
int tipo = int.parse(senhaUsuario.substring(0, 1));
|
||||
// Define a possição inicial da quebra da senha
|
||||
int posI = 0;
|
||||
int posF = 0;
|
||||
int posMax = 0;
|
||||
// Pra cada tipo (1, 2 ou 3) define a posição inicial da quebra da senha
|
||||
if(tipo == 1){
|
||||
posI = 0;
|
||||
posF = 16;
|
||||
posMax = 16;
|
||||
} else if(tipo == 2){
|
||||
posI = 16;
|
||||
posF = 0;
|
||||
posMax = 16;
|
||||
} else if(tipo == 3){
|
||||
posI = 0;
|
||||
posF = 31;
|
||||
posMax = 1;
|
||||
}
|
||||
|
||||
print('posI $posI posF $posF PosMax $posMax');
|
||||
print('inicio ${senhaMD5.substring(0, 16)}');
|
||||
print('meio ${senhaMD5.substring(16, 32)}');
|
||||
print('fim ${senhaMD5.substring(posF, posMax)}');
|
||||
print('senha: ${senhaMD5.substring(posI, posMax) + senha + senhaMD5.substring(posF, posMax)}');
|
||||
print('${grHashString(GRCryptoType.sha1, senhaMD5.substring(posI, posMax) + senha + senhaMD5.substring(posF, posMax))}');
|
||||
|
||||
|
||||
// Faz a criptografia e concatena ela com sha1 e md5
|
||||
String senhaCriptogradafa = tipo.toString() + '\$'+ grHashString(GRCryptoType.sha1, senhaMD5.substring(posI, posMax) + senha + senhaMD5.substring(posF, posMax));
|
||||
// Retorna a senha criptografada
|
||||
return senhaCriptogradafa;
|
||||
}
|
||||
}
|
||||
5
lib/service/url_api_const.dart
Normal file
5
lib/service/url_api_const.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
class UrlApiConst{
|
||||
static const String ApiUrlOnline = 'https://saude.rkmsistemas.com.br/api/atb/';
|
||||
static const String ApiUrlHomologacao = 'https://app0.rkmsistemas.com.br/api/atb/';
|
||||
static const String ApiUrlDesenvolvimento = 'http://192.168.0.42:8010/api/atb/';
|
||||
}
|
||||
Reference in New Issue
Block a user