Skip to content

Instantly share code, notes, and snippets.

View myksao's full-sized avatar
🏠
Working from home

Nimi myksao

🏠
Working from home
View GitHub Profile
@myksao
myksao / struct_extraction.rs
Last active October 5, 2023 22:31
field and value extraction using serde json
use serde::{Deserialize, Serialize};
use serde_json::Value;
pub fn extraction<T: Default + Serialize>(data: &T) -> Value {
let columns = serde_json::to_value(data.clone())
.unwrap()
.as_object()
.unwrap()
.keys()
.map(|key| key.to_string())

The default format of keys was changed in OpenSSL 1.0. From OpenSSL 1.0 change log:

Make PKCS#8 the default write format for private keys, replacing the traditional format. This form is standardised, more secure and doesn't include an implicit MD5 dependency. [Steve Henson]

Good explanations of the difference between the two formats: https://tls.mbed.org/kb/cryptography/asn1-key-structures-in-der-and-pem

Converting RSA private key: