Permalink
Browse files

split signature on several lines to conform to the igc ""specificatio…

…n"": data should be split as 75bytes packets across several lines
  • Loading branch information...
Marc Poulhies
Marc Poulhies committed Apr 11, 2012
1 parent 8cef342 commit 56886b21350eccfcf834fce0f6bd8487a7363d85
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/com/geeksville/location/IGCWriter.java
@@ -151,8 +151,14 @@ public void emitEpilog() {
// sect 3.2, G=security record
try {
final byte[] signature = sig.sign();
- final String sigStr = Base64.encodeToString(signature, Base64.DEFAULT);
- out.println("G" + sigStr);
+ final String sigStr = Base64.encodeToString(signature, Base64.DEFAULT).replaceAll("[\\r\\n]", "");
+
+ for (int i=0; i < sigStr.length() / 75 ; i++){
+ out.println("G" + sigStr.substring(i*75, i*75+75));
+ }
+ if (sigStr.length() % 75 > 0){
+ out.println("G" + sigStr.substring(((int)(sigStr.length() / 75))*75));
+ }
} catch (SignatureException e) {
Log.e("IGCWriter", "Error when signing...");
out.println("GGaggleFailedToSign");

0 comments on commit 56886b2

Please sign in to comment.