diff options
| author | Rusty Wagner <rusty@vector35.com> | 2015-05-13 02:09:39 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2015-05-13 02:15:20 -0400 |
| commit | cd1ac400a80898b1f6394ce518b0ba92f69fa3e1 (patch) | |
| tree | 62b9f2a9f2d06eff4e51855e2516862035c2845a | |
| parent | 4baa6fc4add2b1d9ff32d8eba67621dfdb1cbfd4 (diff) | |
Base64 transform
| -rw-r--r-- | binaryninjaapi.h | 2 | ||||
| -rw-r--r-- | databuffer.cpp | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index ce5e95ae..50a67b3f 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -192,6 +192,8 @@ namespace BinaryNinja std::string ToEscapedString() const; static DataBuffer FromEscapedString(const std::string& src); + std::string ToBase64() const; + static DataBuffer FromBase64(const std::string& src); }; class TemporaryFile: public RefCountObject diff --git a/databuffer.cpp b/databuffer.cpp index 6a0748b4..7814b14e 100644 --- a/databuffer.cpp +++ b/databuffer.cpp @@ -136,6 +136,21 @@ DataBuffer DataBuffer::FromEscapedString(const string& src) } +string DataBuffer::ToBase64() const +{ + char* str = BNDataBufferToBase64(m_buffer); + string result = str; + BNFreeString(str); + return result; +} + + +DataBuffer DataBuffer::FromBase64(const string& src) +{ + return DataBuffer(BNDecodeBase64(src.c_str())); +} + + string BinaryNinja::EscapeString(const string& s) { DataBuffer buffer(s.c_str(), s.size()); |
