Last active
August 29, 2015 14:13
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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