1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | //******************************************************************* // Welcome to CompileJava! // If you experience any issues, please contact us ('More Info') --> //******************************************************************* import java.lang.Math; // headers MUST be above the first class import java.util.Base64; // one class needs to have a main() method public class HelloWorld { public static String toHexString( byte[] bytes ) { StringBuffer sb = new StringBuffer( bytes.length*2 ); for( int i = 0; i < bytes.length; i++ ) { sb.append( toHex(bytes[i] >> 4) ); sb.append( toHex(bytes[i]) ); } return sb.toString(); } private static char toHex(int nibble) { final char[] hexDigit = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' }; return hexDigit[nibble & 0xF]; } // arguments are passed using the text field below this editor public static void main(String[] args) { String pemText="-----BEGIN CERTIFICATE-----"+ "blablabla"+ "-----END CERTIFICATE-----"; byte[] certificateBytes = Base64.getDecoder().decode( pemText.replaceAll("-----(BEGIN|END) CERTIFICATE-----", "").replaceAll("\n", "").getBytes() ); System.out.println(toHexString(certificateBytes)); } } |
Pesquisar neste blogue
Mostrar mensagens com a etiqueta certificates. Mostrar todas as mensagens
Mostrar mensagens com a etiqueta certificates. Mostrar todas as mensagens
quinta-feira, 5 de abril de 2018
How to convert Pem certificate to Hex string in Java (a stackoverflow conglumerate)
quarta-feira, 20 de dezembro de 2017
When we didn't call it a blockchain
Blockchain seems to be one of the buzz words in the tech world right now - at WebSummit 2017 for sure one of the 3 top words i retained - and some hope with a bright future ahead.
For the non tech it's the way bitcoin works.
Trying to learn more about the technology i came across Learn Blockchains by making one.
And a sentence resonated with something i had done in the past
At this point, the idea of a chain should be apparent—each new block contains within itself, the hash of the previous BlockSAFT-PT (Standard Audit File for Tax purposes Portuguese Version) uses this method to easily identify and verify the correctness of a series of invoices and other tax related documents.
Part of my first job was implementing this on what was then OpenERP (now Odoo) in order to get the program certified by the DGCI (Portugal's main Institute of tax related matters). If you wish to take a closer look at file's structure it is available at SAFT-PT XSD.
Each block is formed by
- InvoiceDate
- SystemEntryDate
- InvoiceNo
- GrossTotal
- Hash (hash of the former document thus creating a chain)
DGCI supplies a validator for the file given the public key and the SAFT-PT file.
On any invoice you will find a sequence of 4 characters (corresponding to the 1º, o 11º, o 21º e o 31º digits of the store signature) followed by the name of the certified company.
If you use Odoo and wish to take a look at a base implementation it can be found here - Odoo SAFT-PT- it is not complete and but it should be nice as a basis for a complete implementation.
PS: This article is also available at my LinkedIn.
quarta-feira, 1 de julho de 2015
Before delving into Odoo i would like to share a project that has saved my life a couple of times - signtester .
If you need to sign (re-sign) several jar files take a look at it :)
If you need to sign (re-sign) several jar files take a look at it :)
Etiquetas:
certificates,
java,
multiple sign,
servoy,
signtester,
tool
Subscrever:
Mensagens (Atom)