Skip to content

Instantly share code, notes, and snippets.

@david-martin
Created November 15, 2016 22:34
Show Gist options
  • Save david-martin/6aaa5e3fac5f7505ef64d6ba18853203 to your computer and use it in GitHub Desktop.
Save david-martin/6aaa5e3fac5f7505ef64d6ba18853203 to your computer and use it in GitHub Desktop.
bytes = null;
// look for the Base64 encoded part of the line to decode
// both ssh-rsa and ssh-dss begin with "AAAA" due to the length bytes
for (String part : keyLine.split(" ")) {
if (part.startsWith("AAAA")) {
bytes = Base64.decodeBase64(part);
break;
}
}
if (bytes == null) throw new IllegalArgumentException("no Base64 part to decode");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment