Created
May 23, 2015 21:39
-
-
Save mdelete/3221fa912557f3144fdd to your computer and use it in GitHub Desktop.
Silly but effective public key modulus extraction in Swift
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
func publicKeyHexModulus(key: SecKeyRef) -> String { | |
let s = String(format: "\(key)") | |
let r1 = s.rangeOfString("modulus: ")! | |
let r2 = Range<String.Index>(start: advance(r1.startIndex, count(r1)), end: advance(r1.endIndex, (SecKeyGetBlockSize(key) * 2))) | |
return s.substringWithRange(r2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment