Ir ao conteúdo
  • Cadastre-se

diegodm

Membro Pleno
  • Posts

    28
  • Cadastrado em

  • Última visita

Tudo que diegodm postou

  1. Pessoal, estou pesquisando sobre o assunto para montar uma fechadura eletrônica em minha casa. O mesmo fabricante muitas vezes oferece os leitores nas duas frequências (uma ou outra). Quanto as Tags já existem com as duas frequências embutidas (2 em 1). Se vocês fossem começar esse projeto do zero, escolheriam qual frequência para o leitor? Qual a vantagem e desvantagem de cada uma? Já vi falar que o 125kHz é uma tecnologia antiga (1990) e basicamente é um código de barras. Já o 13.56Mhz é mais novo e é possível gravar informações personalizadas nele. Alguém já teve experiência nessas tags?
  2. Pessoal, bom dia. Estou querendo melhorar o circuito de CFTV da minha casa. Já tenho Câmeras e DVR Wifi Onvif da china a 1 ano e funciona muito bem, mas tudo com fontes individuais e sem nobreak. O que eu pretendo comprar. Nobreak (Esse Nobreak seria para as câmeras, alarme, e portão eletrônico. https://produto.mercadolivre.com.br/MLB-940103451-nobreak-pmotor-porto-eletrnico-digiseno-gate-12-hp-nhs-_JM Bateria https://produto.mercadolivre.com.br/MLB-819755588-bateria-estacionaria-freedom-df1000-70ah-nobreak-e-som-_JM O que eu já tenho Cameras https://www.banggood.com/Digoo-DG-M1X-HD-960P-Wireless-Mini-WIFI-Night-Vision-Smart-Home-Security-IP-Camera-Onvif-Monitor-p-1137839.html?rmmds=mywishlist&cur_warehouse=CN https://www.banggood.com/Digoo-DG-M1Q-960P-2_8mm-Wireless-Mini-WIFI-Night-Vision-Smart-Home-Security-IP-Camera-Onvif-Monitor-p-1123595.html?rmmds=search&ID=41903&cur_warehouse=CN https://www.banggood.com/Digoo-DG-WO1F-Cloud-Storage-3_6mm-Lens-720P-Waterproof-Outdoor-WIFI-Security-IP-Camera-Motion-Detect-p-1194795.html?rmmds=search&cur_warehouse=CN DVR https://www.banggood.com/Digoo-DG-XME-1080P-4-8-12CH-HDMI-P2P-Standalone-ONVIF-NVR-Recorder-For-IP-Camera-Security-System-p-1114900.html?rmmds=mywishlist&cur_warehouse=CN Fonte Eu tenho umas 3 fontes de Notebook paradas de 19.5v quero usar elas no começo e depois comprar uma de 24v. Agora vem minha dúvida. Como quero centralizar tudo no Nobreak e algumas câmeras são 5v e outras câmeras e o DVR 12v. Quero trabalhar com 19.5v ou 24v para a fiação levar a energia até o equipamento e depois regular a tensão na ponta perto do equipamento. Tenho 2 opções de reguladores 24v para 5v. https://pt.aliexpress.com/item/DC-6-24V-12V-24v-to-5V-USB-Output-charger-step-down-Power-Module-Mini-DC/32678102967.html?spm=a2g0s.13010208.99999999.265.Asglx1 https://pt.aliexpress.com/item/1Pcs-5V-USB-Output-Converter-DC-7V-24V-To-5V-3A-Step-Down-Buck-KIS3R33S-Module/32789455531.html?spm=a2g03.search0104.3.2.G8HyRV&ws_ab_test=searchweb0_0,searchweb201602_4_10152_10065_10151_10344_10068_10345_10342_10547_10343_10340_10341_10548_10541_10562_10084_10083_10307_10539_10312_10059_10313_10314_10534_10533_100031_10604_10603_10103_10594_10557_10596_10595_10142_10107_5080020,searchweb201603_14,ppcSwitch_7&algo_expid=6644c523-85d3-42da-a416-6f1e2ea00798-0&algo_pvid=6644c523-85d3-42da-a416-6f1e2ea00798&rmStoreLevelAB=5 E 1 opção de 24v regulável para 5v ou 12v https://pt.aliexpress.com/item/Ultra-small-LM2596-power-supply-module-DC-DC-BUCK-3A-adjustable-buck-module-regulator-ultra-LM2596S/32230209245.html?spm=a2g03.10010108.1000016.1.436bf1bMgr4Co&isOrigTitle=true Dentre estes reguladores acima, qual seria minha melhor opção? Comprar somente o regulável de 24v para 5v ou 12v? Ou misturar? Quero saber dentre as opções qual seria melhor construída. Obrigado.
  3. @Philippe Henrique Logo farei o vídeo. Terminei a parte Web aonde é possível ligar e desligar as luzes, ter acesso ao gráfico online e aos gráficos dos registros do banco de dados.
  4. @Robert Gabriel Da Silva Obrigado, achei muito interessante vou dar uma olhada. @Mestre88 Segue as fotos do projeto pronto, acabei de terminar ele e está funcionando. O ESP-01 se conecta a WiFi e via WebSockets fica conectado em um Raspberry. Toda vez que o cachorro late o Raspberry fica sabendo e agora vou fazer o restante como registrar o horário, me enviar um e-mail, etc. Muito obrigado pelas intruções. Grande abraço. Feliz Ano Novo a todos.
  5. @Mestre88 Tenho um Esp8266 igual ao anexo, ele trabalha com 3.3v. Consigo usar o positivo ou negativo do buzzer da coleira anti-latido para atuar como se fosse um push button? Assim consigo fazer o que preciso não precisando mais do rele. A coleira trabalha com 5v e o Esp8266 com 3.3v. Você disse que "na verdade chega 5V no buzzer, mas como a corrente é pulsante o multímetro marca apenas metade dela". Obrigado.
  6. @Philippe Henrique Ainda não tenho nenhum vídeo. Tenho que terminar a parte de visualizar temperatura e de controlar remotamente o aquário. Mas assim que fizer posto aqui. Mas quero depois disponibilizar todo o material que usei e os códigos fontes dos sistemas.
  7. @Mestre88 Caramba. Que capricho. Muito Obrigado. Vou comprar os componentes e aviso o resultado. Vou deixar aqui um último projeto que fiz. Automatização do Aquaterrario da minha tartaruga utilizando Arduino, Raspberry Pi, ESP8266 e vários sensores com Java Tomcat, Node.js, Socket.io tudo se comunicando via WebSockets
  8. @Mestre88 O sinal seria o do buzzer sim, que quando ativa no multímetro deu 2v. O rele seria para acionar o Arduino mesmo, como se fosse um botão pressionado.
  9. @Mestre88 Obrigado pela resposta. Você poderia colocar quais componentes devo comprar e como ligá-los? Obrigado.
  10. Pessoal. Eu tenho uma coleira anti-latido de cachorro. Ela é alimentada com 6v. Também funciona com 5v do USB. Quando o cachorro late ela tem um microfone que liga um buzzer em alta frequência por 3 segundos. Eu gostaria de interligar ela no meu Arduino para toda vez que ela for acionada eu registre o latido. Medindo o Buzzer verifiquei que quando é acionado chega 2v nele. Como faço para acionar um relê de 5v com estes 2v? Obrigado.
  11. Pessoal, já consegui fazer assinar um arquivo XML da NFS-e com uma Tag e com duas Tags. Mas neste caso a Tag sempre tem um ID. Preciso agora para uma outra prefeitura assinar todo arquivo XML, mas ele não possuí uma Tag específica e nem possuí Id. Preciso assinar o arquivo XML abaixo. <ns3:esConsultarNfsePorRpsEnvio xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.equiplano.com.br/esnfs"><rps><nrRps>200</nrRps><nrEmissorRps>100</nrEmissorRps></rps><prestador><nrInscricaoMunicipal>100</nrInscricaoMunicipal><cnpj>03740709000189</cnpj><idEntidade>12</idEntidade></prestador></ns3:esConsultarNfsePorRpsEnvio> Em um outro software eles especificam desta maneira: informar a tag que será assinada Ex. infRps para RPS, LoteRps para Lote de RPS, etc., se omitida (""), a assinatura será realizada na tag raiz do XML. Mas não estou conseguindo fazer isso no Java. Vou postar os códigos que estou utilizando de assinatura de Duas Tags. Ele carrega tanto o certificado instalado no Windows como o arquivo do certificado. Vou deixar o código completo caso alguém tenha dificuldade em carregar um certificado A1 ou na assinatura de duas tags. CarregaCertificadoA1 carregaCertificadoArquivo = new CarregaCertificadoA1(); CertificadoA1 certificadoA1Arquivo = new CertificadoA1(); certificadoA1Arquivo = carregaCertificadoArquivo.certificadoArquivo("C:/TMP/CertificadoA1.pfx", "1234", TiposKeyStore.PKCS12); CarregaCertificadoA1 carregaCertificadoWindows = new CarregaCertificadoA1(); CertificadoA1 certificadoA1Windows = new CertificadoA1(); certificadoA1Windows = carregaCertificadoWindows.certificadoWindows("agricola e comercia:9294403", ""); AssinadorXMLNovo assinaWindows = new AssinadorXMLNovo(); System.out.println(assinaWindows.assinaNFSe("c:/tmp/XMLAssinar.xml", certificadoA1Windows)); AssinadorXMLNovo assinaArquivo = new AssinadorXMLNovo(); System.out.println(assinaWindows.assinaNFSe("c:/tmp/XMLAssinar.xml", certificadoA1Arquivo)); package br.com.astersoft.nfse.certificado; import java.security.PrivateKey; import javax.xml.crypto.dsig.XMLSignatureFactory; import javax.xml.crypto.dsig.keyinfo.KeyInfo; public class CertificadoA1 { private XMLSignatureFactory signatureFactory; private PrivateKey privateKey; private KeyInfo keyInfo; public XMLSignatureFactory getSignatureFactory() { return signatureFactory; } public void setSignatureFactory(XMLSignatureFactory signatureFactory) { this.signatureFactory = signatureFactory; } public PrivateKey getPrivateKey() { return privateKey; } public void setPrivateKey(PrivateKey privateKey) { this.privateKey = privateKey; } public KeyInfo getKeyInfo() { return keyInfo; } public void setKeyInfo(KeyInfo keyInfo) { this.keyInfo = keyInfo; } } import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import java.io.*; import java.security.*; import java.util.Collections; import javax.xml.crypto.MarshalException; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dsig.dom.DOMSignContext; import javax.xml.crypto.dsig.keyinfo.KeyInfo; import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec; import javax.xml.crypto.dsig.spec.TransformParameterSpec; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import br.com.astersoft.nfse.certificado.CertificadoA1; public class AssinadorXMLNovo { private static final String RPS = "Rps"; private static final String EnviarLoteRpsEnvio = "LoteRps"; private ArrayList<Transform> transformList; private Document document; private NodeList elements; private org.w3c.dom.Element el; private Reference ref; private SignedInfo si; private XMLSignature signature; private DOMSignContext dsc; private Document documentFactory(String xml) throws SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); Document document = factory.newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes())); return document; } private ArrayList<Transform> signatureFactory( XMLSignatureFactory signatureFactory) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { ArrayList<Transform> transformList = new ArrayList<Transform>(); TransformParameterSpec tps = null; Transform envelopedTransform = signatureFactory.newTransform( Transform.ENVELOPED, tps); Transform c14NTransform = signatureFactory.newTransform( "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", tps); transformList.add(envelopedTransform); transformList.add(c14NTransform); return transformList; } private void assinaLoteRpsNFSe(String tipo, XMLSignatureFactory fac, ArrayList<Transform> transformList, PrivateKey privateKey, KeyInfo ki, Document document, int indexNFe) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, MarshalException, XMLSignatureException, javax.xml.crypto.MarshalException { if(tipo.equals(EnviarLoteRpsEnvio)) { this.elements = this.document.getDocumentElement().getElementsByTagName("LoteRps"); } if(tipo.equals(RPS)) { this.elements = this.document.getElementsByTagName("InfRps"); } this.el = (org.w3c.dom.Element) this.elements.item(indexNFe); String id = el.getAttribute("Id"); el.setIdAttribute("Id", true); this.ref = fac.newReference("#" + id, fac.newDigestMethod(DigestMethod.SHA1, null), transformList, null, null); this.si = fac.newSignedInfo(fac.newCanonicalizationMethod( CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec) null), fac .newSignatureMethod(SignatureMethod.RSA_SHA1, null), Collections.singletonList(ref)); this.signature = fac.newXMLSignature(si, ki); this.dsc = new DOMSignContext(privateKey, /*document.getDocumentElement().getElementsByTagName(tipo).item(indexNFe)*/document.getFirstChild()); this.signature.sign(this.dsc); } private void assinaInfRpsNFSe(String tipo, XMLSignatureFactory fac, ArrayList<Transform> transformList, PrivateKey privateKey, KeyInfo ki, Document document, int indexNFe) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, MarshalException, XMLSignatureException, javax.xml.crypto.MarshalException { if(tipo.equals(EnviarLoteRpsEnvio)) { this.elements = this.document.getDocumentElement().getElementsByTagName("LoteRps"); } if(tipo.equals(RPS)) { this.elements = this.document.getElementsByTagName("InfRps"); } this.el = (org.w3c.dom.Element) this.elements.item(indexNFe); String id = el.getAttribute("Id"); el.setIdAttribute("Id", true); this.ref = fac.newReference("#" + id, fac.newDigestMethod(DigestMethod.SHA1, null), transformList, null, null); this.si = fac.newSignedInfo(fac.newCanonicalizationMethod( CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec) null), fac .newSignatureMethod(SignatureMethod.RSA_SHA1, null), Collections.singletonList(ref)); this.signature = fac.newXMLSignature(si, ki); this.dsc = new DOMSignContext(privateKey, document.getDocumentElement().getElementsByTagName(tipo).item(indexNFe)); this.signature.sign(this.dsc); } private String outputXML(Document doc) throws TransformerException { ByteArrayOutputStream os = new ByteArrayOutputStream(); TransformerFactory tf = TransformerFactory.newInstance(); Transformer trans = tf.newTransformer(); trans.transform(new DOMSource(doc), new StreamResult(os)); String xml = os.toString(); if ((xml != null) && (!"".equals(xml))) { xml = xml.replaceAll("\\r\\n", ""); xml = xml.replaceAll(" standalone=\"no\"", ""); } return xml; } public static String lerXML(String fileXML) throws IOException { String linha = ""; StringBuilder xml = new StringBuilder(); BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(fileXML), "ISO8859-1")); while ((linha = in.readLine()) != null) { xml.append(linha); } in.close(); return xml.toString(); } public String assinaNFSe(String caminhoXML, CertificadoA1 certificadoA1) throws Exception { String arquivoXML = lerXML(caminhoXML); this.document = documentFactory(arquivoXML); this.transformList = signatureFactory(certificadoA1.getSignatureFactory()); assinaLoteRpsNFSe(EnviarLoteRpsEnvio, certificadoA1.getSignatureFactory(), this.transformList, certificadoA1.getPrivateKey(), certificadoA1.getKeyInfo(), this.document, 0); for (int i = 0; i < this.document.getDocumentElement().getElementsByTagName(RPS).getLength(); i++) { assinaInfRpsNFSe(RPS, certificadoA1.getSignatureFactory(), this.transformList, certificadoA1.getPrivateKey(), certificadoA1.getKeyInfo(), this.document, i); } return outputXML(this.document); } } package br.com.astersoft.nfse.util; import java.io.FileNotFoundException; import java.io.IOException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.UnrecoverableEntryException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.List; import javax.xml.crypto.dsig.XMLSignatureFactory; import javax.xml.crypto.dsig.keyinfo.KeyInfo; import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory; import javax.xml.crypto.dsig.keyinfo.X509Data; import br.com.astersoft.nfse.certificado.CertificadoA1; public class CarregaCertificadoA1 { private XMLSignatureFactory signatureFactory; private PrivateKey privateKey; private KeyInfo keyInfo; public CertificadoA1 certificadoArquivo(String caminhoKeyStore, String senha, TiposKeyStore tipoKeystore) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, UnrecoverableEntryException { char[] senhaCertificado = senha.toCharArray(); signatureFactory = XMLSignatureFactory.getInstance("DOM"); KeyStore ks = KeyStore.getInstance(tipoKeystore.getValue()); ks.load(new java.io.FileInputStream(caminhoKeyStore), senhaCertificado); KeyStore.PrivateKeyEntry pkEntry = null; Enumeration<String> aliasesEnum = null; aliasesEnum = ks.aliases(); while (aliasesEnum.hasMoreElements()) { String alias = aliasesEnum.nextElement(); if (ks.isKeyEntry(alias)) { pkEntry = (KeyStore.PrivateKeyEntry) ks.getEntry(alias, new KeyStore.PasswordProtection(senhaCertificado)); privateKey = pkEntry.getPrivateKey(); break; } } X509Certificate cert = (X509Certificate) pkEntry.getCertificate(); // info("SubjectDN: " + cert.getSubjectDN().toString()); KeyInfoFactory keyInfoFactory = signatureFactory.getKeyInfoFactory(); List<X509Certificate> x509Content = new ArrayList<X509Certificate>(); x509Content.add(cert); X509Data x509Data = keyInfoFactory.newX509Data(x509Content); keyInfo = keyInfoFactory.newKeyInfo(Collections.singletonList(x509Data)); CertificadoA1 certificadoA1 = new CertificadoA1(); certificadoA1.setKeyInfo(keyInfo); certificadoA1.setPrivateKey(privateKey); certificadoA1.setSignatureFactory(signatureFactory); return certificadoA1; } public CertificadoA1 certificadoWindows(String certificado, String senha) throws KeyStoreException, NoSuchProviderException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableEntryException { signatureFactory = XMLSignatureFactory.getInstance("DOM"); KeyStore ks = null; ks = KeyStore.getInstance("Windows-MY", "SunMSCAPI"); ks.load(null, null); KeyStore.PrivateKeyEntry pkEntry = null; Enumeration<String> aliasesEnum = null; aliasesEnum = ks.aliases(); while (aliasesEnum.hasMoreElements()) { String alias = certificado; // String alias = (String) aliasesEnum.nextElement(); if (ks.isKeyEntry(alias)) { pkEntry = (KeyStore.PrivateKeyEntry) ks.getEntry(alias, new KeyStore.PasswordProtection(senha.toCharArray())); privateKey = pkEntry.getPrivateKey(); break; } } X509Certificate cert = (X509Certificate) pkEntry.getCertificate(); // info("SubjectDN: " + cert.getSubjectDN().toString()); KeyInfoFactory keyInfoFactory = signatureFactory.getKeyInfoFactory(); List<X509Certificate> x509Content = new ArrayList<X509Certificate>(); x509Content.add(cert); X509Data x509Data = keyInfoFactory.newX509Data(x509Content); keyInfo = keyInfoFactory.newKeyInfo(Collections.singletonList(x509Data)); CertificadoA1 certificadoA1 = new CertificadoA1(); certificadoA1.setKeyInfo(keyInfo); certificadoA1.setPrivateKey(privateKey); certificadoA1.setSignatureFactory(signatureFactory); return certificadoA1; } }

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!