-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
33 lines (28 loc) · 1.23 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// OID-ncode
// Copyright (c) 2023 KMX Systems. All rights reserved.
#include "stdext/oid/ncode.hpp"
#include <array>
#include <iostream>
#include <string>
int main()
{
using namespace kmx::oid;
// std::string input_oid= "1.3.6.1.4.1.9.9.492.1.1.3";
// std::string input_oid= "1.3.6.1.4.1.9.9.147.1.2.2.1.1.4.2560";
// std::string input_oid = "4.1.9.9.147.1.290.2.1.1.4.2560";
const std::string input_oid = "1.3.6.1.2.1.4.24.7.1.7.1.4.0.0.0.0.0.2.0.0.1.4.192.168.1.1";
std::array<std::uint8_t, 32> encoded_oid = {0};
std::string decoded_oid;
decoded_oid.resize(64);
auto encoded = encoded_oid.data();
auto encoded_size = encode(input_oid.data(), input_oid.data() + input_oid.size(), encoded);
auto decoded = const_cast<char*>(decoded_oid.data());
auto decoded_size = decode(encoded_oid.data(), encoded_oid.data() + encoded_oid.size(), decoded);
decoded_oid.resize(decoded_size);
std::cout << "input-size=" << input_oid.size() << '\n';
std::cout << "encoded-size=" << encoded_size << '\n';
std::cout << "decoded-size=" << decoded_size << '\n';
std::cout << "decoded-oid=" << decoded_oid << '\n';
std::cout << "same-result=" << (input_oid == decoded_oid) << '\n';
return 0;
}