2012-09-15 21 views
1

我正在使用OpenSSL創建數字簽名。這會生成一個* .b64文件,其中包含文件* .txt,並且此inturn包含數字簽名。使用java提取* .b64文件

如何使用java提取* .b64?

+0

的OpenSSL通常的輸出格式很多選擇......你應該選擇一個更適合你需要。 – nneonneo

+0

OpenSSL的b64格式是一種base-64編碼。 Apache Commons Codec有一個base-64解碼器。請參閱http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html – GreyBeardedGeek

回答

1

您可以使用DatatypeConverter.parseBase64Binary():到Base64編碼的文件內容進行解碼,以獲得數字簽名:

String fileContentsStr = ... 
byte[] decoded = DatatypeConverter.parseBase64Binary(fileContentsStr); 
System.out.println(new String(decoded));