Skip to content

Instantly share code, notes, and snippets.

@ezarko
Last active August 29, 2015 14:13
Show Gist options
  • Save ezarko/a949402ae60b175875fd to your computer and use it in GitHub Desktop.
Save ezarko/a949402ae60b175875fd to your computer and use it in GitHub Desktop.
Converting a Security Identifier from hexadecimal to string. See http://codeimpossible.com/2008/04/07/Converting-a-Security-Identifier-from-binary-to-string/
#!/usr/bin/perl
$_ = join "", @ARGV;
s/^(0105)000000000005([0-9A-F]{40})$/$1$2/
or die "usage: $0 <28 hex pairs>";
print join("-", "S", unpack "c2 V4", pack "H*", $_)."\n"
perl -e '$_=join"",@ARGV;s/^(0105)000000000005([0-9A-F]{40})$/$1$2/||die;print join("-","S",unpack"c2 V4",pack"H*",$_)."\n"' <28 hex pairs>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment